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_CURL
21 # include <curl/curl.h>
22 # if PHP_HTTP_HAVE_EVENT
23 # if PHP_HTTP_HAVE_EVENT2
24 # include <event2/event.h>
25 # include <event2/event_struct.h>
31 #if PHP_HTTP_HAVE_IDN2
33 #elif PHP_HTTP_HAVE_IDN
37 ZEND_DECLARE_MODULE_GLOBALS(php_http
);
39 #ifdef COMPILE_DL_HTTP
43 zend_function_entry http_functions
[] = {
47 PHP_MINIT_FUNCTION(http
);
48 PHP_MSHUTDOWN_FUNCTION(http
);
49 PHP_RSHUTDOWN_FUNCTION(http
);
50 PHP_MINFO_FUNCTION(http
);
52 static zend_module_dep http_module_deps
[] = {
53 ZEND_MOD_REQUIRED("raphf")
54 ZEND_MOD_REQUIRED("propro")
55 ZEND_MOD_REQUIRED("spl")
56 #ifdef PHP_HTTP_HAVE_HASH
57 ZEND_MOD_REQUIRED("hash")
59 #ifdef PHP_HTTP_HAVE_ICONV
60 ZEND_MOD_REQUIRED("iconv")
65 zend_module_entry http_module_entry
= {
66 STANDARD_MODULE_HEADER_EX
,
76 PHP_PECL_HTTP_VERSION
,
77 STANDARD_MODULE_PROPERTIES
80 int http_module_number
;
82 #if PHP_DEBUG && !HAVE_GCOV
83 void _dpf(int type
, const char *data
, size_t length
)
85 static const char _sym
[] = "><><><";
88 for (fprintf(stderr
, "%c ", _sym
[type
-1]); length
--; data
++) {
89 int ip
= PHP_HTTP_IS_CTYPE(print
, *data
);
90 if (!ip
&& *data
!= '\r' && *data
!= '\n') nwp
= 1;
91 fprintf(stderr
, ip
?"%c":"\\x%02x", (int) (*data
& 0xff));
92 if (!nwp
&& *data
== '\n' && length
) {
93 fprintf(stderr
, "\n%c ", _sym
[type
-1]);
96 fprintf(stderr
, "\n");
98 fprintf(stderr
, "# %.*s\n", (int) length
, data
);
103 static void php_http_globals_init_once(zend_php_http_globals
*G
)
105 memset(G
, 0, sizeof(*G
));
109 static inline void php_http_globals_init(zend_php_http_globals
*G TSRMLS_DC
)
113 static inline void php_http_globals_free(zend_php_http_globals
*G TSRMLS_DC
)
118 #if ZTS && PHP_DEBUG && !HAVE_GCOV
119 zend_php_http_globals
*php_http_globals(void)
127 STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL
, OnUpdateString
, env
.etag_mode
, zend_php_http_globals
, php_http_globals
)
130 PHP_MINIT_FUNCTION(http
)
132 http_module_number
= module_number
;
133 ZEND_INIT_MODULE_GLOBALS(php_http
, php_http_globals_init_once
, NULL
);
134 REGISTER_INI_ENTRIES();
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_filter
)
141 || SUCCESS
!= PHP_MINIT_CALL(http_header
)
142 || SUCCESS
!= PHP_MINIT_CALL(http_header_parser
)
143 || SUCCESS
!= PHP_MINIT_CALL(http_message
)
144 || SUCCESS
!= PHP_MINIT_CALL(http_message_parser
)
145 || SUCCESS
!= PHP_MINIT_CALL(http_message_body
)
146 || SUCCESS
!= PHP_MINIT_CALL(http_querystring
)
147 || SUCCESS
!= PHP_MINIT_CALL(http_client
)
148 || SUCCESS
!= PHP_MINIT_CALL(http_client_request
)
149 || SUCCESS
!= PHP_MINIT_CALL(http_client_response
)
150 #if PHP_HTTP_HAVE_CURL
151 || SUCCESS
!= PHP_MINIT_CALL(http_curl
)
152 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl
)
153 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl_user
)
155 || SUCCESS
!= PHP_MINIT_CALL(http_url
)
156 || SUCCESS
!= PHP_MINIT_CALL(http_env
)
157 || SUCCESS
!= PHP_MINIT_CALL(http_env_request
)
158 || SUCCESS
!= PHP_MINIT_CALL(http_env_response
)
159 || SUCCESS
!= PHP_MINIT_CALL(http_params
)
169 PHP_MSHUTDOWN_FUNCTION(http
)
171 UNREGISTER_INI_ENTRIES();
174 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_message
)
175 #if PHP_HTTP_HAVE_CURL
176 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client_curl
)
177 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_curl
)
179 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client
)
187 PHP_RSHUTDOWN_FUNCTION(http
)
190 || SUCCESS
!= PHP_RSHUTDOWN_CALL(http_env
)
198 PHP_MINFO_FUNCTION(http
)
200 php_http_buffer_t buf
;
202 php_http_buffer_init(&buf
);
204 php_info_print_table_start();
205 php_info_print_table_header(2, "HTTP Support", "enabled");
206 php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION
);
207 php_info_print_table_end();
209 php_info_print_table_start();
210 php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
211 php_info_print_table_row(3, "libz", ZLIB_VERSION
, zlibVersion());
212 #if PHP_HTTP_HAVE_CURL
214 curl_version_info_data
*cv
= curl_version_info(CURLVERSION_NOW
);
215 php_info_print_table_row(3, "libcurl", LIBCURL_VERSION
, cv
->version
);
218 php_info_print_table_row(3, "libcurl", "disabled", "disabled");
221 #if PHP_HTTP_HAVE_EVENT
222 php_info_print_table_row(3, "libevent",
223 # ifdef LIBEVENT_VERSION
226 PHP_HTTP_EVENT_VERSION
,
228 event_get_version());
230 php_info_print_table_row(3, "libevent", "disabled", "disabled");
233 #if PHP_HTTP_HAVE_IDN2
234 php_info_print_table_row(3, "libidn2 (IDNA2008)", IDN2_VERSION
, idn2_check_version(NULL
));
235 #elif PHP_HTTP_HAVE_IDN
236 php_info_print_table_row(3, "libidn (IDNA2003)", PHP_HTTP_LIBIDN_VERSION
, "unknown");
239 php_info_print_table_end();
241 DISPLAY_INI_ENTRIES();
250 * vim600: noet sw=4 ts=4 fdm=marker
251 * vim<600: noet sw=4 ts=4