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("spl")
62 #if PHP_HTTP_HAVE_HASH
63 ZEND_MOD_REQUIRED("hash")
65 #if PHP_HTTP_HAVE_ICONV
66 ZEND_MOD_REQUIRED("iconv")
71 zend_module_entry http_module_entry
= {
72 STANDARD_MODULE_HEADER_EX
,
82 PHP_PECL_HTTP_VERSION
,
83 STANDARD_MODULE_PROPERTIES
86 int http_module_number
;
88 #if PHP_DEBUG && !HAVE_GCOV
89 void _dpf(int type
, const char *data
, size_t length
)
91 static const char _sym
[] = "><><><";
94 for (fprintf(stderr
, "%c ", _sym
[type
-1]); length
--; data
++) {
95 int ip
= PHP_HTTP_IS_CTYPE(print
, *data
);
96 if (!ip
&& *data
!= '\r' && *data
!= '\n') nwp
= 1;
97 fprintf(stderr
, ip
?"%c":"\\x%02x", (int) (*data
& 0xff));
98 if (!nwp
&& *data
== '\n' && length
) {
99 fprintf(stderr
, "\n%c ", _sym
[type
-1]);
102 fprintf(stderr
, "\n");
104 fprintf(stderr
, "# %.*s\n", (int) length
, data
);
109 static void php_http_globals_init_once(zend_php_http_globals
*G
)
111 memset(G
, 0, sizeof(*G
));
115 static inline void php_http_globals_init(zend_php_http_globals
*G
)
119 static inline void php_http_globals_free(zend_php_http_globals
*G
)
125 STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL
, OnUpdateString
, env
.etag_mode
, zend_php_http_globals
, php_http_globals
)
128 PHP_MINIT_FUNCTION(http
)
130 http_module_number
= module_number
;
131 ZEND_INIT_MODULE_GLOBALS(php_http
, php_http_globals_init_once
, NULL
);
132 REGISTER_INI_ENTRIES();
135 || SUCCESS
!= PHP_MINIT_CALL(http_object
)
136 || SUCCESS
!= PHP_MINIT_CALL(http_exception
)
137 || SUCCESS
!= PHP_MINIT_CALL(http_cookie
)
138 || SUCCESS
!= PHP_MINIT_CALL(http_encoding
)
139 || SUCCESS
!= PHP_MINIT_CALL(http_encoding_zlib
)
140 #if PHP_HTTP_HAVE_LIBBROTLI
141 || SUCCESS
!= PHP_MINIT_CALL(http_encoding_brotli
)
143 || SUCCESS
!= PHP_MINIT_CALL(http_filter
)
144 || SUCCESS
!= PHP_MINIT_CALL(http_header
)
145 || SUCCESS
!= PHP_MINIT_CALL(http_header_parser
)
146 || SUCCESS
!= PHP_MINIT_CALL(http_message
)
147 || SUCCESS
!= PHP_MINIT_CALL(http_message_parser
)
148 || SUCCESS
!= PHP_MINIT_CALL(http_message_body
)
149 || SUCCESS
!= PHP_MINIT_CALL(http_querystring
)
150 || SUCCESS
!= PHP_MINIT_CALL(http_client
)
151 || SUCCESS
!= PHP_MINIT_CALL(http_client_request
)
152 || SUCCESS
!= PHP_MINIT_CALL(http_client_response
)
153 #if PHP_HTTP_HAVE_LIBCURL
154 || SUCCESS
!= PHP_MINIT_CALL(http_curl
)
155 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl
)
156 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl_user
)
158 || SUCCESS
!= PHP_MINIT_CALL(http_url
)
159 || SUCCESS
!= PHP_MINIT_CALL(http_env
)
160 || SUCCESS
!= PHP_MINIT_CALL(http_env_request
)
161 || SUCCESS
!= PHP_MINIT_CALL(http_env_response
)
162 || SUCCESS
!= PHP_MINIT_CALL(http_params
)
172 PHP_MSHUTDOWN_FUNCTION(http
)
174 UNREGISTER_INI_ENTRIES();
177 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_message
)
178 #if PHP_HTTP_HAVE_LIBCURL
179 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client_curl
)
180 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_curl
)
182 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client
)
190 PHP_RSHUTDOWN_FUNCTION(http
)
193 || SUCCESS
!= PHP_RSHUTDOWN_CALL(http_env
)
201 PHP_MINFO_FUNCTION(http
)
203 php_http_buffer_t buf
;
205 php_http_buffer_init(&buf
);
207 php_info_print_table_start();
208 php_info_print_table_header(2, "HTTP Support", "enabled");
209 php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION
);
210 php_info_print_table_end();
212 php_info_print_table_start();
213 php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
214 php_info_print_table_row(3, "libz", ZLIB_VERSION
, zlibVersion());
215 #if PHP_HTTP_HAVE_LIBCURL
217 curl_version_info_data
*cv
= curl_version_info(CURLVERSION_NOW
);
218 php_info_print_table_row(3, "libcurl", LIBCURL_VERSION
, cv
->version
);
221 php_info_print_table_row(3, "libcurl", "disabled", "disabled");
224 #if PHP_HTTP_HAVE_LIBEVENT
225 php_info_print_table_row(3, "libevent",
226 # ifdef LIBEVENT_VERSION
229 PHP_HTTP_LIBEVENT_VERSION
,
231 event_get_version());
233 php_info_print_table_row(3, "libevent", "disabled", "disabled");
236 #if PHP_HTTP_HAVE_LIBICU
238 UVersionInfo uv
= {0};
239 char us
[U_MAX_VERSION_STRING_LENGTH
] = {0};
242 u_versionToString(uv
, us
);
243 php_info_print_table_row(3, "libicu "
244 #if HAVE_UIDNA_NAMETOASCII_UTF8 && HAVE_UIDNA_IDNTOASCII
245 "(IDNA2008/IDNA2003)"
246 #elif HAVE_UIDNA_NAMETOASCII_UTF8
248 #elif HAVE_UIDNA_IDNTOASCII
251 , U_ICU_VERSION
, us
);
254 php_info_print_table_row(3, "libicu (IDNA2008/IDNA2003)", "disabled", "disabled");
256 #if PHP_HTTP_HAVE_LIBIDN2
257 php_info_print_table_row(3, "libidn2 (IDNA2008)", IDN2_VERSION
, idn2_check_version(NULL
));
259 php_info_print_table_row(3, "libidn2 (IDNA2008)", "disabled", "disabled");
261 #if PHP_HTTP_HAVE_LIBIDN
262 php_info_print_table_row(3, "libidn (IDNA2003)", PHP_HTTP_LIBIDN_VERSION
, "unknown");
264 php_info_print_table_row(3, "libidn (IDNA2003)", "disabled", "disabled");
266 #if PHP_HTTP_HAVE_LIBIDNKIT2
267 php_info_print_table_row(3, "libidnkit2 (IDNA2008)", IDNKIT_VERSION_LIBIDN
, idn_version_libidn());
269 php_info_print_table_row(3, "libidnkit2 (IDNA2008)", "disabled", "disabled");
271 #if PHP_HTTP_HAVE_LIBIDNKIT
272 php_info_print_table_row(3, "libidnkit (IDNA2003)", IDNKIT_VERSION
, idn_version_getstring());
274 php_info_print_table_row(3, "libidnkit (IDNA2003)", "disabled", "disabled");
276 php_info_print_table_end();
278 DISPLAY_INI_ENTRIES();
287 * vim600: noet sw=4 ts=4 fdm=marker
288 * vim<600: noet sw=4 ts=4