2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
16 #include "ext/standard/info.h"
20 #if PHP_HTTP_HAVE_LIBCURL
21 # include <curl/curl.h>
22 # if PHP_HTTP_HAVE_LIBEVENT
23 # if PHP_HTTP_HAVE_LIBEVENT2
24 # include <event2/event.h>
25 # include <event2/event_struct.h>
31 #if PHP_HTTP_HAVE_LIBICU
32 # include <unicode/uversion.h>
34 #if PHP_HTTP_HAVE_LIBIDN
37 #if PHP_HTTP_HAVE_LIBIDN2
40 #if PHP_HTTP_HAVE_LIBIDNKIT2 || PHP_HTTP_HAVE_LIBIDNKIT
41 #include "idn/version.h"
44 ZEND_DECLARE_MODULE_GLOBALS(php_http
);
50 zend_function_entry http_functions
[] = {
54 PHP_MINIT_FUNCTION(http
);
55 PHP_MSHUTDOWN_FUNCTION(http
);
56 PHP_RSHUTDOWN_FUNCTION(http
);
57 PHP_MINFO_FUNCTION(http
);
59 static zend_module_dep http_module_deps
[] = {
60 ZEND_MOD_REQUIRED("raphf")
61 ZEND_MOD_REQUIRED("propro")
62 ZEND_MOD_REQUIRED("spl")
63 #if PHP_HTTP_HAVE_HASH
64 ZEND_MOD_REQUIRED("hash")
66 #if PHP_HTTP_HAVE_ICONV
67 ZEND_MOD_REQUIRED("iconv")
72 zend_module_entry http_module_entry
= {
73 STANDARD_MODULE_HEADER_EX
,
83 PHP_PECL_HTTP_VERSION
,
84 STANDARD_MODULE_PROPERTIES
87 int http_module_number
;
89 #if PHP_DEBUG && !HAVE_GCOV
90 void _dpf(int type
, const char *data
, size_t length
)
92 static const char _sym
[] = "><><><";
95 for (fprintf(stderr
, "%c ", _sym
[type
-1]); length
--; data
++) {
96 int ip
= PHP_HTTP_IS_CTYPE(print
, *data
);
97 if (!ip
&& *data
!= '\r' && *data
!= '\n') nwp
= 1;
98 fprintf(stderr
, ip
?"%c":"\\x%02x", (int) (*data
& 0xff));
99 if (!nwp
&& *data
== '\n' && length
) {
100 fprintf(stderr
, "\n%c ", _sym
[type
-1]);
103 fprintf(stderr
, "\n");
105 fprintf(stderr
, "# %.*s\n", (int) length
, data
);
110 static void php_http_globals_init_once(zend_php_http_globals
*G
)
112 memset(G
, 0, sizeof(*G
));
116 static inline void php_http_globals_init(zend_php_http_globals
*G
)
120 static inline void php_http_globals_free(zend_php_http_globals
*G
)
126 STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL
, OnUpdateString
, env
.etag_mode
, zend_php_http_globals
, php_http_globals
)
129 PHP_MINIT_FUNCTION(http
)
131 http_module_number
= module_number
;
132 ZEND_INIT_MODULE_GLOBALS(php_http
, php_http_globals_init_once
, NULL
);
133 REGISTER_INI_ENTRIES();
136 || SUCCESS
!= PHP_MINIT_CALL(http_object
)
137 || SUCCESS
!= PHP_MINIT_CALL(http_exception
)
138 || SUCCESS
!= PHP_MINIT_CALL(http_cookie
)
139 || SUCCESS
!= PHP_MINIT_CALL(http_encoding
)
140 || SUCCESS
!= PHP_MINIT_CALL(http_encoding_zlib
)
141 #if PHP_HTTP_HAVE_LIBBROTLI
142 || SUCCESS
!= PHP_MINIT_CALL(http_encoding_brotli
)
144 || SUCCESS
!= PHP_MINIT_CALL(http_filter
)
145 || SUCCESS
!= PHP_MINIT_CALL(http_header
)
146 || SUCCESS
!= PHP_MINIT_CALL(http_header_parser
)
147 || SUCCESS
!= PHP_MINIT_CALL(http_message
)
148 || SUCCESS
!= PHP_MINIT_CALL(http_message_parser
)
149 || SUCCESS
!= PHP_MINIT_CALL(http_message_body
)
150 || SUCCESS
!= PHP_MINIT_CALL(http_querystring
)
151 || SUCCESS
!= PHP_MINIT_CALL(http_client
)
152 || SUCCESS
!= PHP_MINIT_CALL(http_client_request
)
153 || SUCCESS
!= PHP_MINIT_CALL(http_client_response
)
154 #if PHP_HTTP_HAVE_LIBCURL
155 || SUCCESS
!= PHP_MINIT_CALL(http_curl
)
156 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl
)
157 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl_user
)
159 || SUCCESS
!= PHP_MINIT_CALL(http_url
)
160 || SUCCESS
!= PHP_MINIT_CALL(http_env
)
161 || SUCCESS
!= PHP_MINIT_CALL(http_env_request
)
162 || SUCCESS
!= PHP_MINIT_CALL(http_env_response
)
163 || SUCCESS
!= PHP_MINIT_CALL(http_params
)
173 PHP_MSHUTDOWN_FUNCTION(http
)
175 UNREGISTER_INI_ENTRIES();
178 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_message
)
179 #if PHP_HTTP_HAVE_LIBCURL
180 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client_curl
)
181 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_curl
)
183 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client
)
191 PHP_RSHUTDOWN_FUNCTION(http
)
194 || SUCCESS
!= PHP_RSHUTDOWN_CALL(http_env
)
202 PHP_MINFO_FUNCTION(http
)
204 php_http_buffer_t buf
;
206 php_http_buffer_init(&buf
);
208 php_info_print_table_start();
209 php_info_print_table_header(2, "HTTP Support", "enabled");
210 php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION
);
211 php_info_print_table_end();
213 php_info_print_table_start();
214 php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
215 php_info_print_table_row(3, "libz", ZLIB_VERSION
, zlibVersion());
216 #if PHP_HTTP_HAVE_LIBCURL
218 curl_version_info_data
*cv
= curl_version_info(CURLVERSION_NOW
);
219 php_info_print_table_row(3, "libcurl", LIBCURL_VERSION
, cv
->version
);
222 php_info_print_table_row(3, "libcurl", "disabled", "disabled");
225 #if PHP_HTTP_HAVE_LIBEVENT
226 php_info_print_table_row(3, "libevent",
227 # ifdef LIBEVENT_VERSION
230 PHP_HTTP_LIBEVENT_VERSION
,
232 event_get_version());
234 php_info_print_table_row(3, "libevent", "disabled", "disabled");
237 #if PHP_HTTP_HAVE_LIBICU
239 UVersionInfo uv
= {0};
240 char us
[U_MAX_VERSION_STRING_LENGTH
] = {0};
243 u_versionToString(uv
, us
);
244 php_info_print_table_row(3, "libicu "
245 #if HAVE_UIDNA_NAMETOASCII_UTF8 && HAVE_UIDNA_IDNTOASCII
246 "(IDNA2008/IDNA2003)"
247 #elif HAVE_UIDNA_NAMETOASCII_UTF8
249 #elif HAVE_UIDNA_IDNTOASCII
252 , U_ICU_VERSION
, us
);
255 php_info_print_table_row(3, "libicu (IDNA2008/IDNA2003)", "disabled", "disabled");
257 #if PHP_HTTP_HAVE_LIBIDN2
258 php_info_print_table_row(3, "libidn2 (IDNA2008)", IDN2_VERSION
, idn2_check_version(NULL
));
260 php_info_print_table_row(3, "libidn2 (IDNA2008)", "disabled", "disabled");
262 #if PHP_HTTP_HAVE_LIBIDN
263 php_info_print_table_row(3, "libidn (IDNA2003)", PHP_HTTP_LIBIDN_VERSION
, "unknown");
265 php_info_print_table_row(3, "libidn (IDNA2003)", "disabled", "disabled");
267 #if PHP_HTTP_HAVE_LIBIDNKIT2
268 php_info_print_table_row(3, "libidnkit2 (IDNA2008)", IDNKIT_VERSION_LIBIDN
, idn_version_libidn());
270 php_info_print_table_row(3, "libidnkit2 (IDNA2008)", "disabled", "disabled");
272 #if PHP_HTTP_HAVE_LIBIDNKIT
273 php_info_print_table_row(3, "libidnkit (IDNA2003)", IDNKIT_VERSION
, idn_version_getstring());
275 php_info_print_table_row(3, "libidnkit (IDNA2003)", "disabled", "disabled");
277 php_info_print_table_end();
279 DISPLAY_INI_ENTRIES();
288 * vim600: noet sw=4 ts=4 fdm=marker
289 * vim<600: noet sw=4 ts=4