- fix requests for the first byte only
[m6w6/ext-http] / php_http.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
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-2007, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #ifndef PHP_EXT_HTTP_H
16 #define PHP_EXT_HTTP_H
17
18 #define PHP_EXT_HTTP_VERSION "1.5.0RC2"
19
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #else
23 # ifndef PHP_WIN32
24 # include "php_config.h"
25 # endif
26 #endif
27
28 #include "php.h"
29 #include "missing.h"
30 #include "php_http_std_defs.h"
31 #include "phpstr/phpstr.h"
32
33 #ifdef HTTP_WANT_SAPI
34 # if PHP_API_VERSION > 20041225
35 # define HTTP_HAVE_SAPI_RTIME
36 # endif
37 # include "SAPI.h"
38 #endif
39
40 #ifdef HTTP_WANT_NETDB
41 # ifdef PHP_WIN32
42 # define HTTP_HAVE_NETDB
43 # include <winsock2.h>
44 # elif defined(HAVE_NETDB_H)
45 # define HTTP_HAVE_NETDB
46 # include <netdb.h>
47 # ifdef HAVE_UNISTD_H
48 # include <unistd.h>
49 # endif
50 # endif
51 #endif
52
53 #if defined(HTTP_WANT_CURL) && defined(HTTP_HAVE_CURL)
54 # ifdef PHP_WIN32
55 # include <winsock2.h>
56 # define CURL_STATICLIB
57 # endif
58 # include <curl/curl.h>
59 # define HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z)))
60 #endif
61
62 #if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
63 # if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
64 # define USE_MAGIC_STATIC
65 # endif
66 # include <magic.h>
67 #endif
68
69 #if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
70 # include <zlib.h>
71 #endif
72
73 #include <ctype.h>
74 #define HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
75 #define HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
76
77 extern zend_module_entry http_module_entry;
78 #define phpext_http_ptr &http_module_entry
79
80 extern int http_module_number;
81
82 ZEND_BEGIN_MODULE_GLOBALS(http)
83
84 struct _http_globals_etag {
85 char *mode;
86 void *ctx;
87 zend_bool started;
88 } etag;
89
90 struct _http_globals_log {
91 char *cache;
92 char *redirect;
93 char *not_found;
94 char *allowed_methods;
95 char *composite;
96 } log;
97
98 struct _http_globals_send {
99 double throttle_delay;
100 size_t buffer_size;
101 char *content_type;
102 char *unquoted_etag;
103 time_t last_modified;
104 struct _http_globals_send_deflate {
105 zend_bool response;
106 zend_bool start_auto;
107 long start_flags;
108 int encoding;
109 void *stream;
110 } deflate;
111 struct _http_globals_send_inflate {
112 zend_bool start_auto;
113 long start_flags;
114 void *stream;
115 } inflate;
116 zend_bool not_found_404;
117 } send;
118
119 struct _http_globals_request {
120 time_t time;
121 HashTable *headers;
122 struct _http_globals_request_methods {
123 char *allowed;
124 struct _http_globals_request_methods_custom {
125 char *ini;
126 int count;
127 void *entries;
128 } custom;
129 } methods;
130 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
131 struct _http_globals_request_datashare {
132 zend_llist handles;
133 zend_bool cookie;
134 zend_bool dns;
135 zend_bool ssl;
136 zend_bool connect;
137 } datashare;
138 #endif
139 } request;
140
141 struct _http_globals_persistent {
142 struct _http_globals_persistent_handles {
143 ulong limit;
144 struct _http_globals_persistent_handles_ident {
145 ulong h;
146 char *s;
147 size_t l;
148 } ident;
149 } handles;
150 } persistent;
151
152 #ifdef ZEND_ENGINE_2
153 zend_bool only_exceptions;
154 #endif
155
156 zend_bool force_exit;
157 zend_bool read_post_data;
158 zval *server_var;
159
160 ZEND_END_MODULE_GLOBALS(http)
161
162 ZEND_EXTERN_MODULE_GLOBALS(http);
163
164 #ifdef ZTS
165 # include "TSRM.h"
166 # define HTTP_G ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
167 #else
168 # define HTTP_G (&http_globals)
169 #endif
170
171 #if defined(HAVE_ICONV) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
172 # define HTTP_HAVE_ICONV
173 #endif
174
175 #if defined(HAVE_PHP_SESSION) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_SESSION))
176 # define HTTP_HAVE_SESSION
177 #endif
178
179 #if defined(HAVE_HASH_EXT) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(HTTP_HAVE_PHP_HASH_H)
180 # define HTTP_HAVE_HASH
181 #endif
182
183 #if defined(HAVE_SPL)
184 # define HTTP_HAVE_SPL
185 #endif
186
187 PHP_FUNCTION(http_date);
188 PHP_FUNCTION(http_build_url);
189 PHP_FUNCTION(http_build_str);
190 PHP_FUNCTION(http_negotiate_language);
191 PHP_FUNCTION(http_negotiate_charset);
192 PHP_FUNCTION(http_negotiate_content_type);
193 PHP_FUNCTION(http_redirect);
194 PHP_FUNCTION(http_throttle);
195 PHP_FUNCTION(http_send_status);
196 PHP_FUNCTION(http_send_last_modified);
197 PHP_FUNCTION(http_send_content_type);
198 PHP_FUNCTION(http_send_content_disposition);
199 PHP_FUNCTION(http_match_modified);
200 PHP_FUNCTION(http_match_etag);
201 PHP_FUNCTION(http_cache_last_modified);
202 PHP_FUNCTION(http_cache_etag);
203 PHP_FUNCTION(http_send_data);
204 PHP_FUNCTION(http_send_file);
205 PHP_FUNCTION(http_send_stream);
206 PHP_FUNCTION(http_chunked_decode);
207 PHP_FUNCTION(http_parse_message);
208 PHP_FUNCTION(http_parse_headers);
209 PHP_FUNCTION(http_parse_cookie);
210 PHP_FUNCTION(http_build_cookie);
211 PHP_FUNCTION(http_parse_params);
212 PHP_FUNCTION(http_get_request_headers);
213 PHP_FUNCTION(http_get_request_body);
214 PHP_FUNCTION(http_get_request_body_stream);
215 PHP_FUNCTION(http_match_request_header);
216 PHP_FUNCTION(http_persistent_handles_count);
217 PHP_FUNCTION(http_persistent_handles_clean);
218 PHP_FUNCTION(http_persistent_handles_ident);
219 #ifdef HTTP_HAVE_CURL
220 PHP_FUNCTION(http_get);
221 PHP_FUNCTION(http_head);
222 PHP_FUNCTION(http_post_data);
223 PHP_FUNCTION(http_post_fields);
224 PHP_FUNCTION(http_put_data);
225 PHP_FUNCTION(http_put_file);
226 PHP_FUNCTION(http_put_stream);
227 PHP_FUNCTION(http_request);
228 PHP_FUNCTION(http_request_body_encode);
229 #endif /* HTTP_HAVE_CURL */
230 PHP_FUNCTION(http_request_method_register);
231 PHP_FUNCTION(http_request_method_unregister);
232 PHP_FUNCTION(http_request_method_exists);
233 PHP_FUNCTION(http_request_method_name);
234 PHP_FUNCTION(ob_etaghandler);
235 #ifdef HTTP_HAVE_ZLIB
236 PHP_FUNCTION(http_deflate);
237 PHP_FUNCTION(http_inflate);
238 PHP_FUNCTION(ob_deflatehandler);
239 PHP_FUNCTION(ob_inflatehandler);
240 #endif
241 PHP_FUNCTION(http_support);
242
243 #endif /* PHP_HTTP_H */
244
245 /*
246 * Local variables:
247 * tab-width: 4
248 * c-basic-offset: 4
249 * End:
250 * vim600: noet sw=4 ts=4 fdm=marker
251 * vim<600: noet sw=4 ts=4
252 */
253