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