- preparations for HttpMessage
[m6w6/ext-http] / php_http.h
1 /*
2 +----------------------------------------------------------------------+
3 | PECL :: http |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.0 of the PHP license, that |
6 | is bundled with this package in the file LICENSE, and is available |
7 | through the world-wide-web at http://www.php.net/license/3_0.txt. |
8 | If you did not receive a copy of the PHP license and are unable to |
9 | obtain it through the world-wide-web, please send a note to |
10 | license@php.net so we can mail you a copy immediately. |
11 +----------------------------------------------------------------------+
12 | Copyright (c) 2004-2005 Michael Wallner <mike@php.net> |
13 +----------------------------------------------------------------------+
14 */
15
16 /* $Id$ */
17
18 #ifndef PHP_EXT_HTTP_H
19 #define PHP_EXT_HTTP_H
20
21 #define HTTP_PEXT_VERSION "0.8.0-dev"
22
23 /* make compile on Win32 */
24 #include "php_streams.h"
25 #include "ext/standard/md5.h"
26 #include "phpstr/phpstr.h"
27 #include "php_http_message_api.h"
28
29 extern zend_module_entry http_module_entry;
30 #define phpext_http_ptr &http_module_entry
31
32 #ifdef ZTS
33 # include "TSRM.h"
34 # define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
35 #else
36 # define HTTP_G(v) (http_globals.v)
37 #endif
38
39 #ifdef ZEND_ENGINE_2
40
41 typedef struct {
42 zend_object zo;
43 http_message *message;
44 } http_message_object;
45
46 typedef struct {
47 zend_object zo;
48 } http_response_object;
49
50 #ifdef HTTP_HAVE_CURL
51
52 #ifdef PHP_WIN32
53 # include <winsock2.h>
54 #endif
55
56 #include <curl/curl.h>
57
58 typedef struct {
59 zend_object zo;
60 CURL *ch;
61 } http_request_object;
62
63 typedef enum {
64 HTTP_GET = 1,
65 HTTP_HEAD,
66 HTTP_POST,
67 } http_request_method;
68
69 #endif /* HTTP_HAVE _CURL */
70
71 PHP_METHOD(HttpUtil, date);
72 PHP_METHOD(HttpUtil, absoluteURI);
73 PHP_METHOD(HttpUtil, negotiateLanguage);
74 PHP_METHOD(HttpUtil, negotiateCharset);
75 PHP_METHOD(HttpUtil, redirect);
76 PHP_METHOD(HttpUtil, sendStatus);
77 PHP_METHOD(HttpUtil, sendLastModified);
78 PHP_METHOD(HttpUtil, sendContentType);
79 PHP_METHOD(HttpUtil, sendContentDisposition);
80 PHP_METHOD(HttpUtil, matchModified);
81 PHP_METHOD(HttpUtil, matchEtag);
82 PHP_METHOD(HttpUtil, cacheLastModified);
83 PHP_METHOD(HttpUtil, cacheEtag);
84 PHP_METHOD(HttpUtil, chunkedDecode);
85 PHP_METHOD(HttpUtil, splitResponse);
86 PHP_METHOD(HttpUtil, parseHeaders);
87 PHP_METHOD(HttpUtil, getRequestHeaders);
88 #ifdef HTTP_HAVE_CURL
89 PHP_METHOD(HttpUtil, get);
90 PHP_METHOD(HttpUtil, head);
91 PHP_METHOD(HttpUtil, postData);
92 PHP_METHOD(HttpUtil, postArray);
93 #endif /* HTTP_HAVE_CURL */
94 PHP_METHOD(HttpUtil, authBasic);
95 PHP_METHOD(HttpUtil, authBasicCallback);
96
97 PHP_METHOD(HttpMessage, __construct);
98 PHP_METHOD(HttpMessage, __destruct);
99
100 PHP_METHOD(HttpResponse, __construct);/*
101 PHP_METHOD(HttpResponse, __destruct);*/
102 PHP_METHOD(HttpResponse, setETag);
103 PHP_METHOD(HttpResponse, getETag);
104 PHP_METHOD(HttpResponse, setContentDisposition);
105 PHP_METHOD(HttpResponse, getContentDisposition);
106 PHP_METHOD(HttpResponse, setContentType);
107 PHP_METHOD(HttpResponse, getContentType);
108 PHP_METHOD(HttpResponse, setCache);
109 PHP_METHOD(HttpResponse, getCache);
110 PHP_METHOD(HttpResponse, setCacheControl);
111 PHP_METHOD(HttpResponse, getCacheControl);
112 PHP_METHOD(HttpResponse, setGzip);
113 PHP_METHOD(HttpResponse, getGzip);
114 PHP_METHOD(HttpResponse, setData);
115 PHP_METHOD(HttpResponse, getData);
116 PHP_METHOD(HttpResponse, setFile);
117 PHP_METHOD(HttpResponse, getFile);
118 PHP_METHOD(HttpResponse, setStream);
119 PHP_METHOD(HttpResponse, getStream);
120 PHP_METHOD(HttpResponse, send);
121
122 #ifdef HTTP_HAVE_CURL
123
124 PHP_METHOD(HttpRequest, __construct);
125 PHP_METHOD(HttpRequest, __destruct);
126 PHP_METHOD(HttpRequest, setOptions);
127 PHP_METHOD(HttpRequest, getOptions);
128 PHP_METHOD(HttpRequest, unsetOptions);
129 PHP_METHOD(HttpRequest, setSslOptions);
130 PHP_METHOD(HttpRequest, getSslOptions);
131 PHP_METHOD(HttpRequest, unsetSslOptions);
132 PHP_METHOD(HttpRequest, addHeaders);
133 PHP_METHOD(HttpRequest, getHeaders);
134 PHP_METHOD(HttpRequest, unsetHeaders);
135 PHP_METHOD(HttpRequest, addCookies);
136 PHP_METHOD(HttpRequest, getCookies);
137 PHP_METHOD(HttpRequest, unsetCookies);
138 PHP_METHOD(HttpRequest, setMethod);
139 PHP_METHOD(HttpRequest, getMethod);
140 PHP_METHOD(HttpRequest, setURL);
141 PHP_METHOD(HttpRequest, getURL);
142 PHP_METHOD(HttpRequest, setContentType);
143 PHP_METHOD(HttpRequest, getContentType);
144 PHP_METHOD(HttpRequest, setQueryData);
145 PHP_METHOD(HttpRequest, getQueryData);
146 PHP_METHOD(HttpRequest, addQueryData);
147 PHP_METHOD(HttpRequest, unsetQueryData);
148 PHP_METHOD(HttpRequest, setPostData);
149 PHP_METHOD(HttpRequest, getPostData);
150 PHP_METHOD(HttpRequest, addPostData);
151 PHP_METHOD(HttpRequest, unsetPostData);
152 PHP_METHOD(HttpRequest, addPostFile);
153 PHP_METHOD(HttpRequest, getPostFiles);
154 PHP_METHOD(HttpRequest, unsetPostFiles);
155 PHP_METHOD(HttpRequest, send);
156 PHP_METHOD(HttpRequest, getResponseData);
157 PHP_METHOD(HttpRequest, getResponseHeader);
158 PHP_METHOD(HttpRequest, getResponseCookie);
159 PHP_METHOD(HttpRequest, getResponseCode);
160 PHP_METHOD(HttpRequest, getResponseBody);
161 PHP_METHOD(HttpRequest, getResponseInfo);
162
163 #endif /* HTTP_HAVE_CURL */
164
165 #endif /* ZEND_ENGINE_2 */
166
167 PHP_FUNCTION(http_test);
168 PHP_FUNCTION(http_date);
169 PHP_FUNCTION(http_absolute_uri);
170 PHP_FUNCTION(http_negotiate_language);
171 PHP_FUNCTION(http_negotiate_charset);
172 PHP_FUNCTION(http_redirect);
173 PHP_FUNCTION(http_send_status);
174 PHP_FUNCTION(http_send_last_modified);
175 PHP_FUNCTION(http_send_content_type);
176 PHP_FUNCTION(http_send_content_disposition);
177 PHP_FUNCTION(http_match_modified);
178 PHP_FUNCTION(http_match_etag);
179 PHP_FUNCTION(http_cache_last_modified);
180 PHP_FUNCTION(http_cache_etag);
181 PHP_FUNCTION(http_send_data);
182 PHP_FUNCTION(http_send_file);
183 PHP_FUNCTION(http_send_stream);
184 PHP_FUNCTION(http_chunked_decode);
185 PHP_FUNCTION(http_split_response);
186 PHP_FUNCTION(http_parse_headers);
187 PHP_FUNCTION(http_get_request_headers);
188 #ifdef HTTP_HAVE_CURL
189 PHP_FUNCTION(http_get);
190 PHP_FUNCTION(http_head);
191 PHP_FUNCTION(http_post_data);
192 PHP_FUNCTION(http_post_array);
193 #endif /* HTTP_HAVE_CURL */
194 PHP_FUNCTION(http_auth_basic);
195 PHP_FUNCTION(http_auth_basic_cb);
196 #ifndef ZEND_ENGINE_2
197 PHP_FUNCTION(http_build_query);
198 #endif /* ZEND_ENGINE_2 */
199 PHP_FUNCTION(ob_httpetaghandler);
200
201 PHP_MINIT_FUNCTION(http);
202 PHP_MSHUTDOWN_FUNCTION(http);
203 PHP_RINIT_FUNCTION(http);
204 PHP_RSHUTDOWN_FUNCTION(http);
205 PHP_MINFO_FUNCTION(http);
206
207 ZEND_BEGIN_MODULE_GLOBALS(http)
208 zend_bool etag_started;
209 PHP_MD5_CTX etag_md5;
210 php_stream_statbuf ssb;
211 char *ctype;
212 char *etag;
213 time_t lmod;
214 char *allowed_methods;
215 #ifdef HTTP_HAVE_CURL
216 phpstr curlbuf;
217 # if LIBCURL_VERSION_NUM < 0x070c00
218 char curlerr[CURL_ERROR_SIZE + 1];
219 # endif
220 zend_llist to_free;
221 #endif /* HTTP_HAVE_CURL */
222 ZEND_END_MODULE_GLOBALS(http)
223
224 #endif /* PHP_HTTP_H */
225
226 /*
227 * Local variables:
228 * tab-width: 4
229 * c-basic-offset: 4
230 * End:
231 * vim600: noet sw=4 ts=4 fdm=marker
232 * vim<600: noet sw=4 ts=4
233 */
234