95624e5e2ef37ffa11ef402ad961ea9bbd96d4b5
[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.7.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
28 extern zend_module_entry http_module_entry;
29 #define phpext_http_ptr &http_module_entry
30
31 #ifdef ZTS
32 # include "TSRM.h"
33 # define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
34 #else
35 # define HTTP_G(v) (http_globals.v)
36 #endif
37
38 #ifdef ZEND_ENGINE_2
39
40 typedef struct {
41 zend_object zo;
42 } http_response_object;
43
44 #ifdef HTTP_HAVE_CURL
45
46 #ifdef PHP_WIN32
47 # include <winsock2.h>
48 #endif
49
50 #include <curl/curl.h>
51
52 typedef struct {
53 zend_object zo;
54 CURL *ch;
55 } http_request_object;
56
57 typedef enum {
58 HTTP_GET = 1,
59 HTTP_HEAD,
60 HTTP_POST,
61 } http_request_method;
62
63 #endif /* HTTP_HAVE _CURL */
64
65 PHP_METHOD(HttpUtil, date);
66 PHP_METHOD(HttpUtil, absoluteURI);
67 PHP_METHOD(HttpUtil, negotiateLanguage);
68 PHP_METHOD(HttpUtil, negotiateCharset);
69 PHP_METHOD(HttpUtil, redirect);
70 PHP_METHOD(HttpUtil, sendStatus);
71 PHP_METHOD(HttpUtil, sendLastModified);
72 PHP_METHOD(HttpUtil, sendContentType);
73 PHP_METHOD(HttpUtil, sendContentDisposition);
74 PHP_METHOD(HttpUtil, matchModified);
75 PHP_METHOD(HttpUtil, matchEtag);
76 PHP_METHOD(HttpUtil, cacheLastModified);
77 PHP_METHOD(HttpUtil, cacheEtag);
78 PHP_METHOD(HttpUtil, chunkedDecode);
79 PHP_METHOD(HttpUtil, splitResponse);
80 PHP_METHOD(HttpUtil, parseHeaders);
81 PHP_METHOD(HttpUtil, getRequestHeaders);
82 #ifdef HTTP_HAVE_CURL
83 PHP_METHOD(HttpUtil, get);
84 PHP_METHOD(HttpUtil, head);
85 PHP_METHOD(HttpUtil, postData);
86 PHP_METHOD(HttpUtil, postArray);
87 #endif /* HTTP_HAVE_CURL */
88 PHP_METHOD(HttpUtil, authBasic);
89 PHP_METHOD(HttpUtil, authBasicCallback);
90
91
92 PHP_METHOD(HttpResponse, __construct);/*
93 PHP_METHOD(HttpResponse, __destruct);*/
94 PHP_METHOD(HttpResponse, setETag);
95 PHP_METHOD(HttpResponse, getETag);
96 PHP_METHOD(HttpResponse, setContentDisposition);
97 PHP_METHOD(HttpResponse, getContentDisposition);
98 PHP_METHOD(HttpResponse, setContentType);
99 PHP_METHOD(HttpResponse, getContentType);
100 PHP_METHOD(HttpResponse, setCache);
101 PHP_METHOD(HttpResponse, getCache);
102 PHP_METHOD(HttpResponse, setCacheControl);
103 PHP_METHOD(HttpResponse, getCacheControl);
104 PHP_METHOD(HttpResponse, setGzip);
105 PHP_METHOD(HttpResponse, getGzip);
106 PHP_METHOD(HttpResponse, setData);
107 PHP_METHOD(HttpResponse, getData);
108 PHP_METHOD(HttpResponse, setFile);
109 PHP_METHOD(HttpResponse, getFile);
110 PHP_METHOD(HttpResponse, setStream);
111 PHP_METHOD(HttpResponse, getStream);
112 PHP_METHOD(HttpResponse, send);
113
114 #ifdef HTTP_HAVE_CURL
115
116 PHP_METHOD(HttpRequest, __construct);
117 PHP_METHOD(HttpRequest, __destruct);
118 PHP_METHOD(HttpRequest, setOptions);
119 PHP_METHOD(HttpRequest, getOptions);
120 PHP_METHOD(HttpRequest, unsetOptions);
121 PHP_METHOD(HttpRequest, addHeader);
122 PHP_METHOD(HttpRequest, addCookie);
123 PHP_METHOD(HttpRequest, setMethod);
124 PHP_METHOD(HttpRequest, getMethod);
125 PHP_METHOD(HttpRequest, setURL);
126 PHP_METHOD(HttpRequest, getURL);
127 PHP_METHOD(HttpRequest, setContentType);
128 PHP_METHOD(HttpRequest, getContentType);
129 PHP_METHOD(HttpRequest, setQueryData);
130 PHP_METHOD(HttpRequest, getQueryData);
131 PHP_METHOD(HttpRequest, addQueryData);
132 PHP_METHOD(HttpRequest, unsetQueryData);
133 PHP_METHOD(HttpRequest, setPostData);
134 PHP_METHOD(HttpRequest, getPostData);
135 PHP_METHOD(HttpRequest, addPostData);
136 PHP_METHOD(HttpRequest, unsetPostData);
137 PHP_METHOD(HttpRequest, addPostFile);
138 PHP_METHOD(HttpRequest, getPostFiles);
139 PHP_METHOD(HttpRequest, unsetPostFiles);
140 PHP_METHOD(HttpRequest, send);
141 PHP_METHOD(HttpRequest, getResponseData);
142 PHP_METHOD(HttpRequest, getResponseHeader);
143 PHP_METHOD(HttpRequest, getResponseCode);
144 PHP_METHOD(HttpRequest, getResponseBody);
145 PHP_METHOD(HttpRequest, getResponseInfo);
146
147 #endif /* HTTP_HAVE_CURL */
148
149 #endif /* ZEND_ENGINE_2 */
150
151 PHP_FUNCTION(http_test);
152 PHP_FUNCTION(http_date);
153 PHP_FUNCTION(http_absolute_uri);
154 PHP_FUNCTION(http_negotiate_language);
155 PHP_FUNCTION(http_negotiate_charset);
156 PHP_FUNCTION(http_redirect);
157 PHP_FUNCTION(http_send_status);
158 PHP_FUNCTION(http_send_last_modified);
159 PHP_FUNCTION(http_send_content_type);
160 PHP_FUNCTION(http_send_content_disposition);
161 PHP_FUNCTION(http_match_modified);
162 PHP_FUNCTION(http_match_etag);
163 PHP_FUNCTION(http_cache_last_modified);
164 PHP_FUNCTION(http_cache_etag);
165 PHP_FUNCTION(http_send_data);
166 PHP_FUNCTION(http_send_file);
167 PHP_FUNCTION(http_send_stream);
168 PHP_FUNCTION(http_chunked_decode);
169 PHP_FUNCTION(http_split_response);
170 PHP_FUNCTION(http_parse_headers);
171 PHP_FUNCTION(http_get_request_headers);
172 #ifdef HTTP_HAVE_CURL
173 PHP_FUNCTION(http_get);
174 PHP_FUNCTION(http_head);
175 PHP_FUNCTION(http_post_data);
176 PHP_FUNCTION(http_post_array);
177 #endif /* HTTP_HAVE_CURL */
178 PHP_FUNCTION(http_auth_basic);
179 PHP_FUNCTION(http_auth_basic_cb);
180 #ifndef ZEND_ENGINE_2
181 PHP_FUNCTION(http_build_query);
182 #endif /* ZEND_ENGINE_2 */
183 PHP_FUNCTION(ob_httpetaghandler);
184
185 PHP_MINIT_FUNCTION(http);
186 PHP_MSHUTDOWN_FUNCTION(http);
187 PHP_RINIT_FUNCTION(http);
188 PHP_RSHUTDOWN_FUNCTION(http);
189 PHP_MINFO_FUNCTION(http);
190
191 ZEND_BEGIN_MODULE_GLOBALS(http)
192 zend_bool etag_started;
193 PHP_MD5_CTX etag_md5;
194 php_stream_statbuf ssb;
195 char *ctype;
196 char *etag;
197 time_t lmod;
198 char *allowed_methods;
199 #ifdef HTTP_HAVE_CURL
200 phpstr curlbuf;
201 zend_llist to_free;
202 #endif /* HTTP_HAVE_CURL */
203 ZEND_END_MODULE_GLOBALS(http)
204
205 #endif /* PHP_HTTP_H */
206
207 /*
208 * Local variables:
209 * tab-width: 4
210 * c-basic-offset: 4
211 * End:
212 * vim600: noet sw=4 ts=4 fdm=marker
213 * vim<600: noet sw=4 ts=4
214 */
215