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_SERF
35 ZEND_DECLARE_MODULE_GLOBALS(php_http
);
37 #ifdef COMPILE_DL_HTTP
41 zend_function_entry http_functions
[] = {
45 PHP_MINIT_FUNCTION(http
);
46 PHP_MSHUTDOWN_FUNCTION(http
);
47 PHP_RSHUTDOWN_FUNCTION(http
);
48 PHP_MINFO_FUNCTION(http
);
50 static zend_module_dep http_module_deps
[] = {
51 ZEND_MOD_REQUIRED("raphf")
52 ZEND_MOD_REQUIRED("propro")
53 ZEND_MOD_REQUIRED("spl")
54 #ifdef PHP_HTTP_HAVE_HASH
55 ZEND_MOD_REQUIRED("hash")
57 #ifdef PHP_HTTP_HAVE_ICONV
58 ZEND_MOD_REQUIRED("iconv")
63 zend_module_entry http_module_entry
= {
64 STANDARD_MODULE_HEADER_EX
,
74 PHP_PECL_HTTP_VERSION
,
75 STANDARD_MODULE_PROPERTIES
78 int http_module_number
;
80 #if PHP_DEBUG && !HAVE_GCOV
81 void _dpf(int type
, const char *data
, size_t length
)
83 static const char _sym
[] = "><><><";
86 for (fprintf(stderr
, "%c ", _sym
[type
-1]); length
--; data
++) {
87 int ip
= PHP_HTTP_IS_CTYPE(print
, *data
);
88 if (!ip
&& *data
!= '\r' && *data
!= '\n') nwp
= 1;
89 fprintf(stderr
, ip
?"%c":"\\x%02x", (int) (*data
& 0xff));
90 if (!nwp
&& *data
== '\n' && length
) {
91 fprintf(stderr
, "\n%c ", _sym
[type
-1]);
94 fprintf(stderr
, "\n");
96 fprintf(stderr
, "# %.*s\n", (int) length
, data
);
101 static void php_http_globals_init_once(zend_php_http_globals
*G
)
103 memset(G
, 0, sizeof(*G
));
107 static inline void php_http_globals_init(zend_php_http_globals
*G TSRMLS_DC
)
111 static inline void php_http_globals_free(zend_php_http_globals
*G TSRMLS_DC
)
117 STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL
, OnUpdateString
, env
.etag_mode
, zend_php_http_globals
, php_http_globals
)
120 PHP_MINIT_FUNCTION(http
)
122 http_module_number
= module_number
;
123 ZEND_INIT_MODULE_GLOBALS(php_http
, php_http_globals_init_once
, NULL
);
124 REGISTER_INI_ENTRIES();
127 || SUCCESS
!= PHP_MINIT_CALL(http_object
)
128 || SUCCESS
!= PHP_MINIT_CALL(http_exception
)
129 || SUCCESS
!= PHP_MINIT_CALL(http_cookie
)
130 || SUCCESS
!= PHP_MINIT_CALL(http_encoding
)
131 || SUCCESS
!= PHP_MINIT_CALL(http_filter
)
132 || SUCCESS
!= PHP_MINIT_CALL(http_header
)
133 || SUCCESS
!= PHP_MINIT_CALL(http_header_parser
)
134 || SUCCESS
!= PHP_MINIT_CALL(http_message
)
135 || SUCCESS
!= PHP_MINIT_CALL(http_message_parser
)
136 || SUCCESS
!= PHP_MINIT_CALL(http_message_body
)
137 || SUCCESS
!= PHP_MINIT_CALL(http_querystring
)
138 || SUCCESS
!= PHP_MINIT_CALL(http_client
)
139 || SUCCESS
!= PHP_MINIT_CALL(http_client_request
)
140 || SUCCESS
!= PHP_MINIT_CALL(http_client_response
)
141 #if PHP_HTTP_HAVE_CURL
142 || SUCCESS
!= PHP_MINIT_CALL(http_curl
)
143 || SUCCESS
!= PHP_MINIT_CALL(http_client_curl
)
145 || SUCCESS
!= PHP_MINIT_CALL(http_url
)
146 || SUCCESS
!= PHP_MINIT_CALL(http_env
)
147 || SUCCESS
!= PHP_MINIT_CALL(http_env_request
)
148 || SUCCESS
!= PHP_MINIT_CALL(http_env_response
)
149 || SUCCESS
!= PHP_MINIT_CALL(http_params
)
159 PHP_MSHUTDOWN_FUNCTION(http
)
161 UNREGISTER_INI_ENTRIES();
164 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_message
)
165 #if PHP_HTTP_HAVE_CURL
166 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client_curl
)
167 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_curl
)
169 || SUCCESS
!= PHP_MSHUTDOWN_CALL(http_client
)
177 PHP_RSHUTDOWN_FUNCTION(http
)
180 || SUCCESS
!= PHP_RSHUTDOWN_CALL(http_env
)
188 PHP_MINFO_FUNCTION(http
)
190 php_http_buffer_t buf
;
192 php_http_buffer_init(&buf
);
194 php_info_print_table_start();
195 php_info_print_table_header(2, "HTTP Support", "enabled");
196 php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION
);
197 php_info_print_table_end();
199 php_info_print_table_start();
200 php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
201 php_info_print_table_row(3, "libz", ZLIB_VERSION
, zlibVersion());
202 #if PHP_HTTP_HAVE_CURL
204 curl_version_info_data
*cv
= curl_version_info(CURLVERSION_NOW
);
205 php_info_print_table_row(3, "libcurl", LIBCURL_VERSION
, cv
->version
);
208 php_info_print_table_row(3, "libcurl", "disabled", "disabled");
211 #if PHP_HTTP_HAVE_EVENT
212 php_info_print_table_row(3, "libevent",
213 # ifdef LIBEVENT_VERSION
216 PHP_HTTP_EVENT_VERSION
,
218 event_get_version());
220 php_info_print_table_row(3, "libevent", "disabled", "disabled");
223 php_info_print_table_end();
225 DISPLAY_INI_ENTRIES();
234 * vim600: noet sw=4 ts=4 fdm=marker
235 * vim<600: noet sw=4 ts=4