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-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
15 #define HTTP_WANT_CURL
18 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
20 #include "zend_interfaces.h"
22 #include "php_http_api.h"
23 #include "php_http_cookie_api.h"
24 #include "php_http_exception_object.h"
25 #include "php_http_message_api.h"
26 #include "php_http_message_object.h"
27 #include "php_http_request_api.h"
28 #include "php_http_request_object.h"
29 #include "php_http_request_pool_api.h"
30 #include "php_http_url_api.h"
32 #define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpRequest, method, 0, req_args)
33 #define HTTP_EMPTY_ARGS(method) HTTP_EMPTY_ARGS_EX(HttpRequest, method, 0)
34 #define HTTP_REQUEST_ME(method, visibility) PHP_ME(HttpRequest, method, HTTP_ARGS(HttpRequest, method), visibility)
35 #define HTTP_REQUEST_ALIAS(method, func) HTTP_STATIC_ME_ALIAS(method, func, HTTP_ARGS(HttpRequest, method))
37 HTTP_BEGIN_ARGS(__construct
, 0)
39 HTTP_ARG_VAL(method
, 0)
40 HTTP_ARG_VAL(options
, 0)
43 HTTP_EMPTY_ARGS(getOptions
);
44 HTTP_BEGIN_ARGS(setOptions
, 0)
45 HTTP_ARG_VAL(options
, 0)
48 HTTP_EMPTY_ARGS(getSslOptions
);
49 HTTP_BEGIN_ARGS(setSslOptions
, 0)
50 HTTP_ARG_VAL(ssl_options
, 0)
53 HTTP_BEGIN_ARGS(addSslOptions
, 0)
54 HTTP_ARG_VAL(ssl_optins
, 0)
57 HTTP_EMPTY_ARGS(getHeaders
);
58 HTTP_BEGIN_ARGS(setHeaders
, 0)
59 HTTP_ARG_VAL(headers
, 0)
62 HTTP_BEGIN_ARGS(addHeaders
, 1)
63 HTTP_ARG_VAL(headers
, 0)
66 HTTP_EMPTY_ARGS(getCookies
);
67 HTTP_BEGIN_ARGS(setCookies
, 0)
68 HTTP_ARG_VAL(cookies
, 0)
71 HTTP_BEGIN_ARGS(addCookies
, 1)
72 HTTP_ARG_VAL(cookies
, 0)
75 HTTP_EMPTY_ARGS(enableCookies
);
76 #if HTTP_CURL_VERSION(7,14,1)
77 HTTP_BEGIN_ARGS(resetCookies
, 0)
78 HTTP_ARG_VAL(session_only
, 0)
82 HTTP_EMPTY_ARGS(getUrl
);
83 HTTP_BEGIN_ARGS(setUrl
, 1)
87 HTTP_EMPTY_ARGS(getMethod
);
88 HTTP_BEGIN_ARGS(setMethod
, 1)
89 HTTP_ARG_VAL(request_method
, 0)
92 HTTP_EMPTY_ARGS(getContentType
);
93 HTTP_BEGIN_ARGS(setContentType
, 1)
94 HTTP_ARG_VAL(content_type
, 0)
97 HTTP_EMPTY_ARGS(getQueryData
);
98 HTTP_BEGIN_ARGS(setQueryData
, 0)
99 HTTP_ARG_VAL(query_data
, 0)
102 HTTP_BEGIN_ARGS(addQueryData
, 1)
103 HTTP_ARG_VAL(query_data
, 0)
106 HTTP_EMPTY_ARGS(getPostFields
);
107 HTTP_BEGIN_ARGS(setPostFields
, 0)
108 HTTP_ARG_VAL(post_fields
, 0)
111 HTTP_BEGIN_ARGS(addPostFields
, 1)
112 HTTP_ARG_VAL(post_fields
, 0)
115 HTTP_EMPTY_ARGS(getPostFiles
);
116 HTTP_BEGIN_ARGS(setPostFiles
, 0)
117 HTTP_ARG_VAL(post_files
, 0)
120 HTTP_BEGIN_ARGS(addPostFile
, 2)
121 HTTP_ARG_VAL(formname
, 0)
122 HTTP_ARG_VAL(filename
, 0)
123 HTTP_ARG_VAL(content_type
, 0)
126 HTTP_EMPTY_ARGS(getRawPostData
);
127 HTTP_BEGIN_ARGS(setRawPostData
, 0)
128 HTTP_ARG_VAL(raw_post_data
, 0)
131 HTTP_BEGIN_ARGS(addRawPostData
, 1)
132 HTTP_ARG_VAL(raw_post_data
, 0)
135 HTTP_EMPTY_ARGS(getPutFile
);
136 HTTP_BEGIN_ARGS(setPutFile
, 0)
137 HTTP_ARG_VAL(filename
, 0)
140 HTTP_EMPTY_ARGS(getPutData
);
141 HTTP_BEGIN_ARGS(setPutData
, 0)
142 HTTP_ARG_VAL(put_data
, 0)
145 HTTP_BEGIN_ARGS(addPutData
, 1)
146 HTTP_ARG_VAL(put_data
, 0)
149 HTTP_EMPTY_ARGS(getResponseData
);
150 HTTP_BEGIN_ARGS(getResponseHeader
, 0)
151 HTTP_ARG_VAL(name
, 0)
154 HTTP_BEGIN_ARGS(getResponseCookies
, 0)
155 HTTP_ARG_VAL(flags
, 0)
156 HTTP_ARG_VAL(allowed_extras
, 0)
159 HTTP_EMPTY_ARGS(getResponseBody
);
160 HTTP_EMPTY_ARGS(getResponseCode
);
161 HTTP_EMPTY_ARGS(getResponseStatus
);
162 HTTP_BEGIN_ARGS(getResponseInfo
, 0)
163 HTTP_ARG_VAL(name
, 0)
166 HTTP_EMPTY_ARGS(getResponseMessage
);
167 HTTP_EMPTY_ARGS(getRawResponseMessage
);
168 HTTP_EMPTY_ARGS(getRequestMessage
);
169 HTTP_EMPTY_ARGS(getRawRequestMessage
);
170 HTTP_EMPTY_ARGS(getHistory
);
171 HTTP_EMPTY_ARGS(clearHistory
);
172 HTTP_EMPTY_ARGS(send
);
174 HTTP_BEGIN_ARGS(get
, 1)
176 HTTP_ARG_VAL(options
, 0)
177 HTTP_ARG_VAL(info
, 1)
180 HTTP_BEGIN_ARGS(head
, 1)
182 HTTP_ARG_VAL(options
, 0)
183 HTTP_ARG_VAL(info
, 1)
186 HTTP_BEGIN_ARGS(postData
, 2)
188 HTTP_ARG_VAL(data
, 0)
189 HTTP_ARG_VAL(options
, 0)
190 HTTP_ARG_VAL(info
, 1)
193 HTTP_BEGIN_ARGS(postFields
, 2)
195 HTTP_ARG_VAL(data
, 0)
196 HTTP_ARG_VAL(options
, 0)
197 HTTP_ARG_VAL(info
, 1)
200 HTTP_BEGIN_ARGS(putData
, 2)
202 HTTP_ARG_VAL(data
, 0)
203 HTTP_ARG_VAL(options
, 0)
204 HTTP_ARG_VAL(info
, 1)
207 HTTP_BEGIN_ARGS(putFile
, 2)
209 HTTP_ARG_VAL(file
, 0)
210 HTTP_ARG_VAL(options
, 0)
211 HTTP_ARG_VAL(info
, 1)
214 HTTP_BEGIN_ARGS(putStream
, 2)
216 HTTP_ARG_VAL(stream
, 0)
217 HTTP_ARG_VAL(options
, 0)
218 HTTP_ARG_VAL(info
, 1)
221 HTTP_BEGIN_ARGS(methodRegister
, 1)
222 HTTP_ARG_VAL(method_name
, 0)
225 HTTP_BEGIN_ARGS(methodUnregister
, 1)
226 HTTP_ARG_VAL(method
, 0)
229 HTTP_BEGIN_ARGS(methodName
, 1)
230 HTTP_ARG_VAL(method_id
, 0)
233 HTTP_BEGIN_ARGS(methodExists
, 1)
234 HTTP_ARG_VAL(method
, 0)
237 #ifdef HAVE_CURL_GETFORMDATA
238 HTTP_BEGIN_ARGS(encodeBody
, 2)
239 HTTP_ARG_VAL(fields
, 0)
240 HTTP_ARG_VAL(files
, 0)
244 #define OBJ_PROP_CE http_request_object_ce
245 zend_class_entry
*http_request_object_ce
;
246 zend_function_entry http_request_object_fe
[] = {
247 HTTP_REQUEST_ME(__construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
249 HTTP_REQUEST_ME(setOptions
, ZEND_ACC_PUBLIC
)
250 HTTP_REQUEST_ME(getOptions
, ZEND_ACC_PUBLIC
)
251 HTTP_REQUEST_ME(setSslOptions
, ZEND_ACC_PUBLIC
)
252 HTTP_REQUEST_ME(getSslOptions
, ZEND_ACC_PUBLIC
)
253 HTTP_REQUEST_ME(addSslOptions
, ZEND_ACC_PUBLIC
)
255 HTTP_REQUEST_ME(addHeaders
, ZEND_ACC_PUBLIC
)
256 HTTP_REQUEST_ME(getHeaders
, ZEND_ACC_PUBLIC
)
257 HTTP_REQUEST_ME(setHeaders
, ZEND_ACC_PUBLIC
)
259 HTTP_REQUEST_ME(addCookies
, ZEND_ACC_PUBLIC
)
260 HTTP_REQUEST_ME(getCookies
, ZEND_ACC_PUBLIC
)
261 HTTP_REQUEST_ME(setCookies
, ZEND_ACC_PUBLIC
)
263 HTTP_REQUEST_ME(enableCookies
, ZEND_ACC_PUBLIC
)
264 #if HTTP_CURL_VERSION(7,14,1)
265 HTTP_REQUEST_ME(resetCookies
, ZEND_ACC_PUBLIC
)
268 HTTP_REQUEST_ME(setMethod
, ZEND_ACC_PUBLIC
)
269 HTTP_REQUEST_ME(getMethod
, ZEND_ACC_PUBLIC
)
271 HTTP_REQUEST_ME(setUrl
, ZEND_ACC_PUBLIC
)
272 HTTP_REQUEST_ME(getUrl
, ZEND_ACC_PUBLIC
)
274 HTTP_REQUEST_ME(setContentType
, ZEND_ACC_PUBLIC
)
275 HTTP_REQUEST_ME(getContentType
, ZEND_ACC_PUBLIC
)
277 HTTP_REQUEST_ME(setQueryData
, ZEND_ACC_PUBLIC
)
278 HTTP_REQUEST_ME(getQueryData
, ZEND_ACC_PUBLIC
)
279 HTTP_REQUEST_ME(addQueryData
, ZEND_ACC_PUBLIC
)
281 HTTP_REQUEST_ME(setPostFields
, ZEND_ACC_PUBLIC
)
282 HTTP_REQUEST_ME(getPostFields
, ZEND_ACC_PUBLIC
)
283 HTTP_REQUEST_ME(addPostFields
, ZEND_ACC_PUBLIC
)
285 HTTP_REQUEST_ME(setRawPostData
, ZEND_ACC_PUBLIC
)
286 HTTP_REQUEST_ME(getRawPostData
, ZEND_ACC_PUBLIC
)
287 HTTP_REQUEST_ME(addRawPostData
, ZEND_ACC_PUBLIC
)
289 HTTP_REQUEST_ME(setPostFiles
, ZEND_ACC_PUBLIC
)
290 HTTP_REQUEST_ME(addPostFile
, ZEND_ACC_PUBLIC
)
291 HTTP_REQUEST_ME(getPostFiles
, ZEND_ACC_PUBLIC
)
293 HTTP_REQUEST_ME(setPutFile
, ZEND_ACC_PUBLIC
)
294 HTTP_REQUEST_ME(getPutFile
, ZEND_ACC_PUBLIC
)
296 HTTP_REQUEST_ME(setPutData
, ZEND_ACC_PUBLIC
)
297 HTTP_REQUEST_ME(getPutData
, ZEND_ACC_PUBLIC
)
298 HTTP_REQUEST_ME(addPutData
, ZEND_ACC_PUBLIC
)
300 HTTP_REQUEST_ME(send
, ZEND_ACC_PUBLIC
)
302 HTTP_REQUEST_ME(getResponseData
, ZEND_ACC_PUBLIC
)
303 HTTP_REQUEST_ME(getResponseHeader
, ZEND_ACC_PUBLIC
)
304 HTTP_REQUEST_ME(getResponseCookies
, ZEND_ACC_PUBLIC
)
305 HTTP_REQUEST_ME(getResponseCode
, ZEND_ACC_PUBLIC
)
306 HTTP_REQUEST_ME(getResponseStatus
, ZEND_ACC_PUBLIC
)
307 HTTP_REQUEST_ME(getResponseBody
, ZEND_ACC_PUBLIC
)
308 HTTP_REQUEST_ME(getResponseInfo
, ZEND_ACC_PUBLIC
)
309 HTTP_REQUEST_ME(getResponseMessage
, ZEND_ACC_PUBLIC
)
310 HTTP_REQUEST_ME(getRawResponseMessage
, ZEND_ACC_PUBLIC
)
311 HTTP_REQUEST_ME(getRequestMessage
, ZEND_ACC_PUBLIC
)
312 HTTP_REQUEST_ME(getRawRequestMessage
, ZEND_ACC_PUBLIC
)
313 HTTP_REQUEST_ME(getHistory
, ZEND_ACC_PUBLIC
)
314 HTTP_REQUEST_ME(clearHistory
, ZEND_ACC_PUBLIC
)
316 HTTP_REQUEST_ALIAS(get
, http_get
)
317 HTTP_REQUEST_ALIAS(head
, http_head
)
318 HTTP_REQUEST_ALIAS(postData
, http_post_data
)
319 HTTP_REQUEST_ALIAS(postFields
, http_post_fields
)
320 HTTP_REQUEST_ALIAS(putData
, http_put_data
)
321 HTTP_REQUEST_ALIAS(putFile
, http_put_file
)
322 HTTP_REQUEST_ALIAS(putStream
, http_put_stream
)
324 HTTP_REQUEST_ALIAS(methodRegister
, http_request_method_register
)
325 HTTP_REQUEST_ALIAS(methodUnregister
, http_request_method_unregister
)
326 HTTP_REQUEST_ALIAS(methodName
, http_request_method_name
)
327 HTTP_REQUEST_ALIAS(methodExists
, http_request_method_exists
)
328 #ifdef HAVE_CURL_GETFORMDATA
329 HTTP_REQUEST_ALIAS(encodeBody
, http_request_body_encode
)
333 static zend_object_handlers http_request_object_handlers
;
335 PHP_MINIT_FUNCTION(http_request_object
)
337 HTTP_REGISTER_CLASS_EX(HttpRequest
, http_request_object
, NULL
, 0);
338 http_request_object_handlers
.clone_obj
= _http_request_object_clone_obj
;
340 DCL_PROP_N(PRIVATE
, options
);
341 DCL_PROP_N(PRIVATE
, postFields
);
342 DCL_PROP_N(PRIVATE
, postFiles
);
343 DCL_PROP_N(PRIVATE
, responseInfo
);
344 DCL_PROP_N(PRIVATE
, responseData
);
345 DCL_PROP_N(PRIVATE
, responseMessage
);
346 DCL_PROP(PRIVATE
, long, responseCode
, 0);
347 DCL_PROP(PRIVATE
, string
, responseStatus
, "");
348 DCL_PROP(PRIVATE
, long, method
, HTTP_GET
);
349 DCL_PROP(PRIVATE
, string
, url
, "");
350 DCL_PROP(PRIVATE
, string
, contentType
, "");
351 DCL_PROP(PRIVATE
, string
, rawPostData
, "");
352 DCL_PROP(PRIVATE
, string
, queryData
, "");
353 DCL_PROP(PRIVATE
, string
, putFile
, "");
354 DCL_PROP(PRIVATE
, string
, putData
, "");
355 DCL_PROP_N(PRIVATE
, history
);
356 DCL_PROP(PUBLIC
, bool, recordHistory
, 0);
360 * Request Method Constants
363 DCL_CONST(long, "METH_GET", HTTP_GET
);
364 DCL_CONST(long, "METH_HEAD", HTTP_HEAD
);
365 DCL_CONST(long, "METH_POST", HTTP_POST
);
366 DCL_CONST(long, "METH_PUT", HTTP_PUT
);
367 DCL_CONST(long, "METH_DELETE", HTTP_DELETE
);
368 DCL_CONST(long, "METH_OPTIONS", HTTP_OPTIONS
);
369 DCL_CONST(long, "METH_TRACE", HTTP_TRACE
);
370 DCL_CONST(long, "METH_CONNECT", HTTP_CONNECT
);
371 /* WebDAV - RFC 2518 */
372 DCL_CONST(long, "METH_PROPFIND", HTTP_PROPFIND
);
373 DCL_CONST(long, "METH_PROPPATCH", HTTP_PROPPATCH
);
374 DCL_CONST(long, "METH_MKCOL", HTTP_MKCOL
);
375 DCL_CONST(long, "METH_COPY", HTTP_COPY
);
376 DCL_CONST(long, "METH_MOVE", HTTP_MOVE
);
377 DCL_CONST(long, "METH_LOCK", HTTP_LOCK
);
378 DCL_CONST(long, "METH_UNLOCK", HTTP_UNLOCK
);
379 /* WebDAV Versioning - RFC 3253 */
380 DCL_CONST(long, "METH_VERSION_CONTROL", HTTP_VERSION_CONTROL
);
381 DCL_CONST(long, "METH_REPORT", HTTP_REPORT
);
382 DCL_CONST(long, "METH_CHECKOUT", HTTP_CHECKOUT
);
383 DCL_CONST(long, "METH_CHECKIN", HTTP_CHECKIN
);
384 DCL_CONST(long, "METH_UNCHECKOUT", HTTP_UNCHECKOUT
);
385 DCL_CONST(long, "METH_MKWORKSPACE", HTTP_MKWORKSPACE
);
386 DCL_CONST(long, "METH_UPDATE", HTTP_UPDATE
);
387 DCL_CONST(long, "METH_LABEL", HTTP_LABEL
);
388 DCL_CONST(long, "METH_MERGE", HTTP_MERGE
);
389 DCL_CONST(long, "METH_BASELINE_CONTROL", HTTP_BASELINE_CONTROL
);
390 DCL_CONST(long, "METH_MKACTIVITY", HTTP_MKACTIVITY
);
391 /* WebDAV Access Control - RFC 3744 */
392 DCL_CONST(long, "METH_ACL", HTTP_ACL
);
395 * HTTP Protocol Version Constants
397 DCL_CONST(long, "VERSION_1_0", CURL_HTTP_VERSION_1_0
);
398 DCL_CONST(long, "VERSION_1_1", CURL_HTTP_VERSION_1_1
);
399 DCL_CONST(long, "VERSION_NONE", CURL_HTTP_VERSION_NONE
);
404 DCL_CONST(long, "AUTH_BASIC", CURLAUTH_BASIC
);
405 DCL_CONST(long, "AUTH_DIGEST", CURLAUTH_DIGEST
);
406 DCL_CONST(long, "AUTH_NTLM", CURLAUTH_NTLM
);
407 DCL_CONST(long, "AUTH_ANY", CURLAUTH_ANY
);
410 * Proxy Type Constants
412 # if HTTP_CURL_VERSION(7,15,2)
413 DCL_CONST(long, "PROXY_SOCKS4", CURLPROXY_SOCKS4
);
415 DCL_CONST(long, "PROXY_SOCKS5", CURLPROXY_SOCKS5
);
416 DCL_CONST(long, "PROXY_HTTP", CURLPROXY_HTTP
);
422 zend_object_value
_http_request_object_new(zend_class_entry
*ce TSRMLS_DC
)
424 return http_request_object_new_ex(ce
, NULL
, NULL
);
427 zend_object_value
_http_request_object_new_ex(zend_class_entry
*ce
, CURL
*ch
, http_request_object
**ptr TSRMLS_DC
)
429 zend_object_value ov
;
430 http_request_object
*o
;
432 o
= ecalloc(1, sizeof(http_request_object
));
434 o
->request
= http_request_init_ex(NULL
, ch
, 0, NULL
);
440 ALLOC_HASHTABLE(OBJ_PROP(o
));
441 zend_hash_init(OBJ_PROP(o
), zend_hash_num_elements(&ce
->default_properties
), NULL
, ZVAL_PTR_DTOR
, 0);
442 zend_hash_copy(OBJ_PROP(o
), &ce
->default_properties
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
444 ov
.handle
= putObject(http_request_object
, o
);
445 ov
.handlers
= &http_request_object_handlers
;
450 zend_object_value
_http_request_object_clone_obj(zval
*this_ptr TSRMLS_DC
)
453 zend_object_value new_ov
;
454 http_request_object
*new_obj
;
455 getObject(http_request_object
, old_obj
);
457 old_zo
= zend_objects_get_address(this_ptr TSRMLS_CC
);
458 new_ov
= http_request_object_new_ex(old_zo
->ce
, NULL
, &new_obj
);
459 if (old_obj
->request
->ch
) {
460 http_curl_init_ex(curl_easy_duphandle(old_obj
->request
->ch
), new_obj
->request
);
463 zend_objects_clone_members(&new_obj
->zo
, new_ov
, old_zo
, Z_OBJ_HANDLE_P(this_ptr
) TSRMLS_CC
);
464 phpstr_append(&new_obj
->request
->conv
.request
, old_obj
->request
->conv
.request
.data
, old_obj
->request
->conv
.request
.used
);
465 phpstr_append(&new_obj
->request
->conv
.response
, old_obj
->request
->conv
.response
.data
, old_obj
->request
->conv
.response
.used
);
470 void _http_request_object_free(zend_object
*object TSRMLS_DC
)
472 http_request_object
*o
= (http_request_object
*) object
;
474 http_request_free(&o
->request
);
478 #define http_request_object_check_request_content_type(t) _http_request_object_check_request_content_type((t) TSRMLS_CC)
479 static inline void _http_request_object_check_request_content_type(zval
*this_ptr TSRMLS_DC
)
481 zval
*ctype
= GET_PROP(contentType
);
483 if (Z_STRLEN_P(ctype
)) {
484 zval
**headers
, *opts
= GET_PROP(options
);
486 if ( (Z_TYPE_P(opts
) == IS_ARRAY
) &&
487 (SUCCESS
== zend_hash_find(Z_ARRVAL_P(opts
), "headers", sizeof("headers"), (void *) &headers
)) &&
488 (Z_TYPE_PP(headers
) == IS_ARRAY
)) {
491 /* only override if not already set */
492 if ((SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(headers
), "Content-Type", sizeof("Content-Type"), (void *) &ct_header
))) {
493 add_assoc_stringl(*headers
, "Content-Type", Z_STRVAL_P(ctype
), Z_STRLEN_P(ctype
), 1);
495 /* or not a string, zero length string or a string of spaces */
496 if ((Z_TYPE_PP(ct_header
) != IS_STRING
) || !Z_STRLEN_PP(ct_header
)) {
497 add_assoc_stringl(*headers
, "Content-Type", Z_STRVAL_P(ctype
), Z_STRLEN_P(ctype
), 1);
499 int i
, only_space
= 1;
501 /* check for spaces only */
502 for (i
= 0; i
< Z_STRLEN_PP(ct_header
); ++i
) {
503 if (!isspace(Z_STRVAL_PP(ct_header
)[i
])) {
509 add_assoc_stringl(*headers
, "Content-Type", Z_STRVAL_P(ctype
), Z_STRLEN_P(ctype
), 1);
515 MAKE_STD_ZVAL(headers
);
517 add_assoc_stringl(headers
, "Content-Type", Z_STRVAL_P(ctype
), Z_STRLEN_P(ctype
), 1);
518 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "addheaders", NULL
, headers
);
519 zval_ptr_dtor(&headers
);
524 STATUS
_http_request_object_requesthandler(http_request_object
*obj
, zval
*this_ptr TSRMLS_DC
)
526 STATUS status
= SUCCESS
;
528 http_request_reset(obj
->request
);
529 HTTP_CHECK_CURL_INIT(obj
->request
->ch
, http_curl_init(obj
->request
), return FAILURE
);
531 obj
->request
->url
= http_absolute_url(Z_STRVAL_P(GET_PROP(url
)));
533 switch (obj
->request
->meth
= Z_LVAL_P(GET_PROP(method
)))
541 zval
*put_data
= GET_PROP(putData
);
543 http_request_object_check_request_content_type(getThis());
544 if (Z_STRLEN_P(put_data
)) {
545 obj
->request
->body
= http_request_body_init_ex(obj
->request
->body
, HTTP_REQUEST_BODY_CSTRING
,
546 estrndup(Z_STRVAL_P(put_data
), Z_STRLEN_P(put_data
)), Z_STRLEN_P(put_data
), 1);
548 php_stream_statbuf ssb
;
549 php_stream
*stream
= php_stream_open_wrapper_ex(Z_STRVAL_P(GET_PROP(putFile
)), "rb", REPORT_ERRORS
|ENFORCE_SAFE_MODE
, NULL
, HTTP_DEFAULT_STREAM_CONTEXT
);
551 if (stream
&& !php_stream_stat(stream
, &ssb
)) {
552 obj
->request
->body
= http_request_body_init_ex(obj
->request
->body
, HTTP_REQUEST_BODY_UPLOADFILE
, stream
, ssb
.sb
.st_size
, 1);
563 /* check for raw post data */
564 zval
*raw_data
= GET_PROP(rawPostData
);
566 if (Z_STRLEN_P(raw_data
)) {
567 http_request_object_check_request_content_type(getThis());
568 obj
->request
->body
= http_request_body_init_ex(obj
->request
->body
, HTTP_REQUEST_BODY_CSTRING
,
569 estrndup(Z_STRVAL_P(raw_data
), Z_STRLEN_P(raw_data
)), Z_STRLEN_P(raw_data
), 1);
571 zval
*zfields
= GET_PROP(postFields
), *zfiles
= GET_PROP(postFiles
);
575 fields
= (Z_TYPE_P(zfields
) == IS_ARRAY
) ? Z_ARRVAL_P(zfields
) : NULL
;
576 files
= (Z_TYPE_P(zfiles
) == IS_ARRAY
) ? Z_ARRVAL_P(zfiles
) : NULL
;
578 if ((fields
&& zend_hash_num_elements(fields
)) || (files
&& zend_hash_num_elements(files
))) {
579 if (!(obj
->request
->body
= http_request_body_fill(obj
->request
->body
, fields
, files
))) {
588 if (status
== SUCCESS
) {
589 zval
*qdata
= GET_PROP(queryData
);
590 zval
*options
= GET_PROP(options
);
592 if (Z_STRLEN_P(qdata
)) {
593 if (!strchr(obj
->request
->url
, '?')) {
594 strlcat(obj
->request
->url
, "?", HTTP_URL_MAXLEN
);
596 strlcat(obj
->request
->url
, "&", HTTP_URL_MAXLEN
);
598 strlcat(obj
->request
->url
, Z_STRVAL_P(qdata
), HTTP_URL_MAXLEN
);
601 http_request_prepare(obj
->request
, Z_ARRVAL_P(options
));
603 /* check if there's a onProgress method and add it as progress callback if one isn't already set */
604 if (zend_hash_exists(&Z_OBJCE_P(getThis())->function_table
, "onprogress", sizeof("onprogress"))) {
607 if ( (Z_TYPE_P(options
) != IS_ARRAY
)
608 || (SUCCESS
!= zend_hash_find(Z_ARRVAL_P(options
), "onprogress", sizeof("onprogress"), (void *) &entry
)
609 || (!zval_is_true(*entry
)))) {
612 ZVAL_ADDREF(getThis());
613 add_next_index_zval(pcb
, getThis());
614 add_next_index_stringl(pcb
, "onprogress", lenof("onprogress"), 1);
615 http_request_set_progress_callback(obj
->request
, pcb
);
624 STATUS
_http_request_object_responsehandler(http_request_object
*obj
, zval
*this_ptr TSRMLS_DC
)
630 /* always fetch info */
633 http_request_info(obj
->request
, Z_ARRVAL_P(info
));
634 SET_PROP(responseInfo
, info
);
635 zval_ptr_dtor(&info
);
637 /* parse response message */
638 phpstr_fix(&obj
->request
->conv
.request
);
639 phpstr_fix(&obj
->request
->conv
.response
);
641 if ((msg
= http_message_parse(PHPSTR_VAL(&obj
->request
->conv
.response
), PHPSTR_LEN(&obj
->request
->conv
.response
)))) {
644 zval
*headers
, *message
, *resp
;
646 if (zval_is_true(GET_PROP(recordHistory
))) {
647 zval
*hist
, *history
= GET_PROP(history
);
648 http_message
*response
= http_message_parse(PHPSTR_VAL(&obj
->request
->conv
.response
), PHPSTR_LEN(&obj
->request
->conv
.response
));
649 http_message
*request
= http_message_parse(PHPSTR_VAL(&obj
->request
->conv
.request
), PHPSTR_LEN(&obj
->request
->conv
.request
));
652 ZVAL_OBJVAL(hist
, http_message_object_new_ex(http_message_object_ce
, http_message_interconnect(response
, request
), NULL
), 0);
653 if (Z_TYPE_P(history
) == IS_OBJECT
) {
654 http_message_object_prepend(hist
, history
);
656 SET_PROP(history
, hist
);
657 zval_ptr_dtor(&hist
);
660 UPD_PROP(long, responseCode
, msg
->http
.info
.response
.code
);
661 UPD_PROP(string
, responseStatus
, msg
->http
.info
.response
.status
? msg
->http
.info
.response
.status
: "");
665 MAKE_STD_ZVAL(headers
);
667 zend_hash_copy(Z_ARRVAL_P(headers
), &msg
->hdrs
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
668 add_assoc_zval(resp
, "headers", headers
);
669 phpstr_data(PHPSTR(msg
), &body
, &body_len
);
670 add_assoc_stringl(resp
, "body", body
, body_len
, 0);
671 SET_PROP(responseData
, resp
);
672 zval_ptr_dtor(&resp
);
674 MAKE_STD_ZVAL(message
);
675 ZVAL_OBJVAL(message
, http_message_object_new_ex(http_message_object_ce
, msg
, NULL
), 0);
676 SET_PROP(responseMessage
, message
);
677 zval_ptr_dtor(&message
);
681 /* update properties with empty values*/
682 zval
*resp
= GET_PROP(responseData
), *znull
;
684 MAKE_STD_ZVAL(znull
);
686 SET_PROP(responseMessage
, znull
);
687 zval_ptr_dtor(&znull
);
689 if (Z_TYPE_P(resp
) == IS_ARRAY
) {
690 zend_hash_clean(Z_ARRVAL_P(resp
));
693 UPD_PROP(long, responseCode
, 0);
694 UPD_PROP(string
, responseStatus
, "");
696 /* append request message to history */
697 if (zval_is_true(GET_PROP(recordHistory
))) {
698 http_message
*request
;
700 if ((request
= http_message_parse(PHPSTR_VAL(&obj
->request
->conv
.request
), PHPSTR_LEN(&obj
->request
->conv
.request
)))) {
701 zval
*hist
, *history
= GET_PROP(history
);
704 ZVAL_OBJVAL(hist
, http_message_object_new_ex(http_message_object_ce
, request
, NULL
), 0);
705 if (Z_TYPE_P(history
) == IS_OBJECT
) {
706 http_message_object_prepend(hist
, history
);
708 SET_PROP(history
, hist
);
709 zval_ptr_dtor(&hist
);
716 if (!EG(exception
) && zend_hash_exists(&Z_OBJCE_P(getThis())->function_table
, "onfinish", sizeof("onfinish"))) {
719 MAKE_STD_ZVAL(param
);
720 ZVAL_BOOL(param
, ret
== SUCCESS
);
721 with_error_handling(EH_NORMAL
, NULL
) {
722 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "onfinish", NULL
, param
);
723 } end_error_handling();
724 zval_ptr_dtor(¶m
);
730 static int apply_pretty_key(void *pDest
, int num_args
, va_list args
, zend_hash_key
*hash_key
)
732 if (hash_key
->nKeyLength
> 1) {
733 hash_key
->h
= zend_get_hash_value(pretty_key(hash_key
->arKey
, hash_key
->nKeyLength
- 1, 1, 0), hash_key
->nKeyLength
);
735 return ZEND_HASH_APPLY_KEEP
;
738 #define http_request_object_set_options_subr(key, ow, pk) \
739 _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAM_PASSTHRU, (key), sizeof(key), (ow), (pk))
740 static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAMETERS
, char *key
, size_t len
, int overwrite
, int prettify_keys
)
742 zval
*old_opts
, *new_opts
, *opts
= NULL
, **entry
= NULL
;
744 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a/!", &opts
)) {
748 MAKE_STD_ZVAL(new_opts
);
749 array_init(new_opts
);
750 old_opts
= GET_PROP(options
);
751 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
752 array_copy(old_opts
, new_opts
);
755 if (prettify_keys
&& opts
) {
756 zend_hash_apply_with_arguments(Z_ARRVAL_P(opts
), apply_pretty_key
, 0);
758 if (SUCCESS
== zend_hash_find(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &entry
)) {
760 zend_hash_clean(Z_ARRVAL_PP(entry
));
762 if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
764 array_copy(opts
, *entry
);
766 array_merge(opts
, *entry
);
771 add_assoc_zval(new_opts
, key
, opts
);
773 SET_PROP(options
, new_opts
);
774 zval_ptr_dtor(&new_opts
);
779 #define http_request_object_get_options_subr(key) \
780 _http_request_get_options_subr(INTERNAL_FUNCTION_PARAM_PASSTHRU, (key), sizeof(key))
781 static inline void _http_request_get_options_subr(INTERNAL_FUNCTION_PARAMETERS
, char *key
, size_t len
)
785 if (return_value_used
) {
786 zval
*opts
, **options
;
788 opts
= GET_PROP(options
);
789 array_init(return_value
);
791 if ( (Z_TYPE_P(opts
) == IS_ARRAY
) &&
792 (SUCCESS
== zend_hash_find(Z_ARRVAL_P(opts
), key
, len
, (void *) &options
))) {
793 convert_to_array(*options
);
794 array_copy(*options
, return_value
);
800 /* ### USERLAND ### */
802 /* {{{ proto void HttpRequest::__construct([string url[, int request_method = HTTP_METH_GET[, array options]]])
804 * Instantiate a new HttpRequest object.
806 * Accepts a string as optional parameter containing the target request url.
807 * Additionally accepts an optional int parameter specifying the request method
808 * to use and an associative array as optional third parameter which will be
809 * passed to HttpRequest::setOptions().
811 * Throws HttpException.
813 PHP_METHOD(HttpRequest
, __construct
)
818 zval
*options
= NULL
;
821 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|sla", &URL
, &URL_len
, &meth
, &options
)) {
823 UPD_STRL(url
, URL
, URL_len
);
826 UPD_PROP(long, method
, meth
);
829 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "setoptions", NULL
, options
);
836 /* {{{ proto bool HttpRequest::setOptions([array options])
838 * Set the request options to use. See http_get() for a full list of available options.
840 * Accepts an array as optional parameters, which values will overwrite the
841 * currently set request options. If the parameter is empty or omitted,
842 * the options of the HttpRequest object will be reset.
844 * Returns TRUE on success, or FALSE on failure.
846 PHP_METHOD(HttpRequest
, setOptions
)
851 zval
*opts
= NULL
, *old_opts
, *new_opts
, *add_opts
, **opt
;
853 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
857 MAKE_STD_ZVAL(new_opts
);
858 array_init(new_opts
);
860 if (!opts
|| !zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
861 SET_PROP(options
, new_opts
);
862 zval_ptr_dtor(&new_opts
);
866 MAKE_STD_ZVAL(add_opts
);
867 array_init(add_opts
);
868 /* some options need extra attention -- thus cannot use array_merge() directly */
869 FOREACH_KEYVAL(pos
, opts
, key
, idx
, opt
) {
871 if (!strcmp(key
, "headers")) {
872 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "addheaders", NULL
, *opt
);
873 } else if (!strcmp(key
, "cookies")) {
874 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "addcookies", NULL
, *opt
);
875 } else if (!strcmp(key
, "ssl")) {
876 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "addssloptions", NULL
, *opt
);
877 } else if ((!strcasecmp(key
, "url")) || (!strcasecmp(key
, "uri"))) {
878 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "seturl", NULL
, *opt
);
879 } else if (!strcmp(key
, "method")) {
880 zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL
, "setmethod", NULL
, *opt
);
881 #if HTTP_CURL_VERSION(7,14,1)
882 } else if (!strcmp(key
, "resetcookies")) {
883 getObject(http_request_object
, obj
);
884 http_request_reset_cookies(obj
->request
, 0);
886 } else if (!strcmp(key
, "enablecookies")) {
887 getObject(http_request_object
, obj
);
888 http_request_enable_cookies(obj
->request
);
889 } else if (!strcasecmp(key
, "recordHistory")) {
890 UPD_PROP(bool, recordHistory
, 1);
893 add_assoc_zval(add_opts
, key
, *opt
);
900 old_opts
= GET_PROP(options
);
901 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
902 array_copy(old_opts
, new_opts
);
904 array_merge(add_opts
, new_opts
);
905 SET_PROP(options
, new_opts
);
906 zval_ptr_dtor(&new_opts
);
907 zval_ptr_dtor(&add_opts
);
913 /* {{{ proto array HttpRequest::getOptions()
915 * Get currently set options.
917 * Returns an associative array containing currently set options.
919 PHP_METHOD(HttpRequest
, getOptions
)
923 if (return_value_used
) {
924 RETURN_PROP(options
);
929 /* {{{ proto bool HttpRequest::setSslOptions([array options])
933 * Accepts an associative array as parameter containing any SSL specific options.
934 * If the parameter is empty or omitted, the SSL options will be reset.
936 * Returns TRUE on success, or FALSE on failure.
938 PHP_METHOD(HttpRequest
, setSslOptions
)
940 http_request_object_set_options_subr("ssl", 1, 0);
944 /* {{{ proto bool HttpRequest::addSslOptions(array options)
946 * Set additional SSL options.
948 * Expects an associative array as parameter containing additional SSL specific options.
950 * Returns TRUE on success, or FALSE on failure.
952 PHP_METHOD(HttpRequest
, addSslOptions
)
954 http_request_object_set_options_subr("ssl", 0, 0);
958 /* {{{ proto array HttpRequest::getSslOtpions()
960 * Get previously set SSL options.
962 * Returns an associative array containing any previously set SSL options.
964 PHP_METHOD(HttpRequest
, getSslOptions
)
966 http_request_object_get_options_subr("ssl");
970 /* {{{ proto bool HttpRequest::addHeaders(array headers)
972 * Add request header name/value pairs.
974 * Expects an associative array as parameter containing additional header
977 * Returns TRUE on success, or FALSE on failure.
979 PHP_METHOD(HttpRequest
, addHeaders
)
981 http_request_object_set_options_subr("headers", 0, 1);
984 /* {{{ proto bool HttpRequest::setHeaders([array headers])
986 * Set request header name/value pairs.
988 * Accepts an associative array as parameter containing header name/value pairs.
989 * If the parameter is empty or omitted, all previously set headers will be unset.
991 * Returns TRUE on success, or FALSE on failure.
993 PHP_METHOD(HttpRequest
, setHeaders
)
995 http_request_object_set_options_subr("headers", 1, 1);
999 /* {{{ proto array HttpRequest::getHeaders()
1001 * Get previously set request headers.
1003 * Returns an associative array containing all currently set headers.
1005 PHP_METHOD(HttpRequest
, getHeaders
)
1007 http_request_object_get_options_subr("headers");
1011 /* {{{ proto bool HttpRequest::setCookies([array cookies])
1015 * Accepts an associative array as parameter containing cookie name/value pairs.
1016 * If the parameter is empty or omitted, all previously set cookies will be unset.
1018 * Returns TRUE on success, or FALSE on failure.
1020 PHP_METHOD(HttpRequest
, setCookies
)
1022 http_request_object_set_options_subr("cookies", 1, 0);
1026 /* {{{ proto bool HttpRequest::addCookies(array cookies)
1030 * Expects an associative array as parameter containing any cookie name/value
1033 * Returns TRUE on success, or FALSE on failure.
1035 PHP_METHOD(HttpRequest
, addCookies
)
1037 http_request_object_set_options_subr("cookies", 0, 0);
1041 /* {{{ proto array HttpRequest::getCookies()
1043 * Get previously set cookies.
1045 * Returns an associative array containing any previously set cookies.
1047 PHP_METHOD(HttpRequest
, getCookies
)
1049 http_request_object_get_options_subr("cookies");
1053 /* {{{ proto bool HttpRequest::enableCookies()
1055 * Enable automatic sending of received cookies.
1056 * Note that cuutomly set cookies will be sent anyway.
1058 PHP_METHOD(HttpRequest
, enableCookies
)
1061 getObject(http_request_object
, obj
);
1062 RETURN_SUCCESS(http_request_enable_cookies(obj
->request
));
1068 /* {{{ proto bool HttpRequest::resetCookies([bool session_only = FALSE])
1070 * Reset all automatically received/sent cookies.
1071 * Note that customly set cookies are not affected.
1073 * Accepts an optional bool parameter specifying
1074 * whether only session cookies should be reset
1075 * (needs libcurl >= v7.15.4, else libcurl >= v7.14.1).
1077 * Returns TRUE on success, or FALSE on failure.
1079 PHP_METHOD(HttpRequest
, resetCookies
)
1081 zend_bool session_only
= 0;
1082 getObject(http_request_object
, obj
);
1084 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &session_only
)) {
1087 RETURN_SUCCESS(http_request_reset_cookies(obj
->request
, session_only
));
1091 /* {{{ proto bool HttpRequest::setUrl(string url)
1093 * Set the request URL.
1095 * Expects a string as parameter specifying the request url.
1097 * Returns TRUE on success, or FALSE on failure.
1099 PHP_METHOD(HttpRequest
, setUrl
)
1104 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &URL
, &URL_len
)) {
1108 UPD_STRL(url
, URL
, URL_len
);
1113 /* {{{ proto string HttpRequest::getUrl()
1115 * Get the previously set request URL.
1117 * Returns the currently set request url as string.
1119 PHP_METHOD(HttpRequest
, getUrl
)
1123 if (return_value_used
) {
1129 /* {{{ proto bool HttpRequest::setMethod(int request_method)
1131 * Set the request method.
1133 * Expects an int as parameter specifying the request method to use.
1134 * In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.
1136 * Returns TRUE on success, or FALSE on failure.
1138 PHP_METHOD(HttpRequest
, setMethod
)
1142 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &meth
)) {
1146 UPD_PROP(long, method
, meth
);
1151 /* {{{ proto int HttpRequest::getMethod()
1153 * Get the previously set request method.
1155 * Returns the currently set request method.
1157 PHP_METHOD(HttpRequest
, getMethod
)
1161 if (return_value_used
) {
1162 RETURN_PROP(method
);
1167 /* {{{ proto bool HttpRequest::setContentType(string content_type)
1169 * Set the content type the post request should have.
1171 * Expects a string as parameters containing the content type of the request
1172 * (primary/secondary).
1174 * Returns TRUE on success, or FALSE if the content type does not seem to
1175 * contain a primary and a secondary part.
1177 PHP_METHOD(HttpRequest
, setContentType
)
1182 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &ctype
, &ct_len
)) {
1187 HTTP_CHECK_CONTENT_TYPE(ctype
, RETURN_FALSE
);
1189 UPD_STRL(contentType
, ctype
, ct_len
);
1194 /* {{{ proto string HttpRequest::getContentType()
1196 * Get the previously content type.
1198 * Returns the previously set content type as string.
1200 PHP_METHOD(HttpRequest
, getContentType
)
1204 if (return_value_used
) {
1205 RETURN_PROP(contentType
);
1210 /* {{{ proto bool HttpRequest::setQueryData([mixed query_data])
1212 * Set the URL query parameters to use, overwriting previously set query parameters.
1213 * Affects any request types.
1215 * Accepts a string or associative array parameter containing the pre-encoded
1216 * query string or to be encoded query fields. If the parameter is empty or
1217 * omitted, the query data will be unset.
1219 * Returns TRUE on success, or FALSE on failure.
1221 PHP_METHOD(HttpRequest
, setQueryData
)
1225 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z!", &qdata
)) {
1229 if ((!qdata
) || Z_TYPE_P(qdata
) == IS_NULL
) {
1230 UPD_STRL(queryData
, "", 0);
1231 } else if ((Z_TYPE_P(qdata
) == IS_ARRAY
) || (Z_TYPE_P(qdata
) == IS_OBJECT
)) {
1232 char *query_data
= NULL
;
1234 if (SUCCESS
!= http_urlencode_hash(HASH_OF(qdata
), &query_data
)) {
1238 UPD_PROP(string
, queryData
, query_data
);
1243 convert_to_string_ex(&qdata
);
1244 UPD_STRL(queryData
, Z_STRVAL_P(qdata
), Z_STRLEN_P(qdata
));
1245 if (orig
!= qdata
) {
1246 zval_ptr_dtor(&qdata
);
1253 /* {{{ proto string HttpRequest::getQueryData()
1255 * Get the current query data in form of an urlencoded query string.
1257 * Returns a string containing the urlencoded query.
1259 PHP_METHOD(HttpRequest
, getQueryData
)
1263 if (return_value_used
) {
1264 RETURN_PROP(queryData
);
1269 /* {{{ proto bool HttpRequest::addQueryData(array query_params)
1271 * Add parameters to the query parameter list, leaving previously set unchanged.
1272 * Affects any request type.
1274 * Expects an associative array as parameter containing the query fields to add.
1276 * Returns TRUE on success, or FALSE on failure.
1278 PHP_METHOD(HttpRequest
, addQueryData
)
1280 zval
*qdata
, *old_qdata
;
1281 char *query_data
= NULL
;
1282 size_t query_data_len
= 0;
1284 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a/", &qdata
)) {
1288 old_qdata
= GET_PROP(queryData
);
1290 if (SUCCESS
!= http_urlencode_hash_ex(HASH_OF(qdata
), 1, Z_STRVAL_P(old_qdata
), Z_STRLEN_P(old_qdata
), &query_data
, &query_data_len
)) {
1294 UPD_STRL(queryData
, query_data
, query_data_len
);
1301 /* {{{ proto bool HttpRequest::addPostFields(array post_data)
1303 * Adds POST data entries, leaving previously set unchanged, unless a
1304 * post entry with the same name already exists.
1305 * Affects only POST and custom requests.
1307 * Expects an associative array as parameter containing the post fields.
1309 * Returns TRUE on success, or FALSE on failure.
1311 PHP_METHOD(HttpRequest
, addPostFields
)
1313 zval
*post_data
, *old_post
, *new_post
;
1315 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a/", &post_data
)) {
1319 if (zend_hash_num_elements(Z_ARRVAL_P(post_data
))) {
1320 MAKE_STD_ZVAL(new_post
);
1321 array_init(new_post
);
1322 old_post
= GET_PROP(postFields
);
1323 if (Z_TYPE_P(old_post
) == IS_ARRAY
) {
1324 array_copy(old_post
, new_post
);
1326 array_merge(post_data
, new_post
);
1327 SET_PROP(postFields
, new_post
);
1328 zval_ptr_dtor(&new_post
);
1335 /* {{{ proto bool HttpRequest::setPostFields([array post_data])
1337 * Set the POST data entries, overwriting previously set POST data.
1338 * Affects only POST and custom requests.
1340 * Accepts an associative array as parameter containing the post fields.
1341 * If the parameter is empty or omitted, the post data will be unset.
1343 * Returns TRUE on success, or FALSE on failure.
1345 PHP_METHOD(HttpRequest
, setPostFields
)
1347 zval
*post
, *post_data
= NULL
;
1349 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a/!", &post_data
)) {
1353 MAKE_STD_ZVAL(post
);
1355 if (post_data
&& zend_hash_num_elements(Z_ARRVAL_P(post_data
))) {
1356 array_copy(post_data
, post
);
1358 SET_PROP(postFields
, post
);
1359 zval_ptr_dtor(&post
);
1365 /* {{{ proto array HttpRequest::getPostFields()
1367 * Get previously set POST data.
1369 * Returns the currently set post fields as associative array.
1371 PHP_METHOD(HttpRequest
, getPostFields
)
1375 if (return_value_used
) {
1376 RETURN_PROP(postFields
);
1381 /* {{{ proto bool HttpRequest::setRawPostData([string raw_post_data])
1383 * Set raw post data to send, overwriting previously set raw post data. Don't
1384 * forget to specify a content type. Affects only POST and custom requests.
1385 * Only either post fields or raw post data can be used for each request.
1386 * Raw post data has higher precedence and will be used even if post fields
1389 * Accepts a string as parameter containing the *raw* post data.
1391 * Returns TRUE on success, or FALSE on failure.
1393 PHP_METHOD(HttpRequest
, setRawPostData
)
1395 char *raw_data
= NULL
;
1398 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &raw_data
, &data_len
)) {
1406 UPD_STRL(rawPostData
, raw_data
, data_len
);
1411 /* {{{ proto bool HttpRequest::addRawPostData(string raw_post_data)
1413 * Add raw post data, leaving previously set raw post data unchanged.
1414 * Affects only POST and custom requests.
1416 * Expects a string as parameter containing the raw post data to concatenate.
1418 * Returns TRUE on success, or FALSE on failure.
1420 PHP_METHOD(HttpRequest
, addRawPostData
)
1425 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &raw_data
, &data_len
)) {
1430 zval
*data
= GET_PROP(rawPostData
);
1432 if (Z_STRLEN_P(data
)) {
1433 Z_STRVAL_P(data
) = erealloc(Z_STRVAL_P(data
), (Z_STRLEN_P(data
) += data_len
) + 1);
1434 Z_STRVAL_P(data
)[Z_STRLEN_P(data
)] = '\0';
1435 memcpy(Z_STRVAL_P(data
) + Z_STRLEN_P(data
) - data_len
, raw_data
, data_len
);
1437 UPD_STRL(putData
, raw_data
, data_len
);
1445 /* {{{ proto string HttpRequest::getRawPostData()
1447 * Get previously set raw post data.
1449 * Returns a string containing the currently set raw post data.
1451 PHP_METHOD(HttpRequest
, getRawPostData
)
1455 if (return_value_used
) {
1456 RETURN_PROP(rawPostData
);
1461 /* {{{ proto bool HttpRequest::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])
1463 * Add a file to the POST request, leaving previously set files unchanged.
1464 * Affects only POST and custom requests. Cannot be used with raw post data.
1466 * Expects a string parameter containing the form element name, and a string
1467 * paremeter containing the path to the file which should be uploaded.
1468 * Additionally accepts an optional string parameter which should contain
1469 * the content type of the file.
1471 * Returns TRUE on success, or FALSE if the content type seems not to contain a
1472 * primary and a secondary content type part.
1474 PHP_METHOD(HttpRequest
, addPostFile
)
1476 zval
*entry
, *old_post
, *new_post
;
1477 char *name
, *file
, *type
= NULL
;
1478 int name_len
, file_len
, type_len
= 0;
1480 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss|s", &name
, &name_len
, &file
, &file_len
, &type
, &type_len
)) {
1485 HTTP_CHECK_CONTENT_TYPE(type
, RETURN_FALSE
);
1487 type
= "application/x-octetstream";
1488 type_len
= sizeof("application/x-octetstream") - 1;
1491 MAKE_STD_ZVAL(entry
);
1494 add_assoc_stringl(entry
, "name", name
, name_len
, 1);
1495 add_assoc_stringl(entry
, "type", type
, type_len
, 1);
1496 add_assoc_stringl(entry
, "file", file
, file_len
, 1);
1498 MAKE_STD_ZVAL(new_post
);
1499 array_init(new_post
);
1500 old_post
= GET_PROP(postFiles
);
1501 if (Z_TYPE_P(old_post
) == IS_ARRAY
) {
1502 array_copy(old_post
, new_post
);
1504 add_next_index_zval(new_post
, entry
);
1505 SET_PROP(postFiles
, new_post
);
1506 zval_ptr_dtor(&new_post
);
1512 /* {{{ proto bool HttpRequest::setPostFiles([array post_files])
1514 * Set files to post, overwriting previously set post files.
1515 * Affects only POST and requests. Cannot be used with raw post data.
1517 * Accepts an array containing the files to post. Each entry should be an
1518 * associative array with "name", "file" and "type" keys. If the parameter
1519 * is empty or omitted the post files will be unset.
1521 * Returns TRUE on success, or FALSE on failure.
1523 PHP_METHOD(HttpRequest
, setPostFiles
)
1525 zval
*files
= NULL
, *post
;
1527 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a!/", &files
)) {
1531 MAKE_STD_ZVAL(post
);
1533 if (files
&& (Z_TYPE_P(files
) == IS_ARRAY
)) {
1534 array_copy(files
, post
);
1536 SET_PROP(postFiles
, post
);
1537 zval_ptr_dtor(&post
);
1543 /* {{{ proto array HttpRequest::getPostFiles()
1545 * Get all previously added POST files.
1547 * Returns an array containing currently set post files.
1549 PHP_METHOD(HttpRequest
, getPostFiles
)
1553 if (return_value_used
) {
1554 RETURN_PROP(postFiles
);
1559 /* {{{ proto bool HttpRequest::setPutFile([string file])
1561 * Set file to put. Affects only PUT requests.
1563 * Accepts a string as parameter referencing the path to file.
1564 * If the parameter is empty or omitted the put file will be unset.
1566 * Returns TRUE on success, or FALSE on failure.
1568 PHP_METHOD(HttpRequest
, setPutFile
)
1573 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &file
, &file_len
)) {
1577 UPD_STRL(putFile
, file
, file_len
);
1582 /* {{{ proto string HttpRequest::getPutFile()
1584 * Get previously set put file.
1586 * Returns a string containing the path to the currently set put file.
1588 PHP_METHOD(HttpRequest
, getPutFile
)
1592 if (return_value_used
) {
1593 RETURN_PROP(putFile
);
1598 /* {{{ proto bool HttpRequest::setPutData([string put_data])
1600 * Set PUT data to send, overwriting previously set PUT data.
1601 * Affects only PUT requests.
1602 * Only either PUT data or PUT file can be used for each request.
1603 * PUT data has higher precedence and will be used even if a PUT
1606 * Accepts a string as parameter containing the data to upload.
1608 * Returns TRUE on success, or FALSE on failure.
1610 PHP_METHOD(HttpRequest
, setPutData
)
1612 char *put_data
= NULL
;
1615 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &put_data
, &data_len
)) {
1623 UPD_STRL(putData
, put_data
, data_len
);
1628 /* {{{ proto bool HttpRequest::addPutData(string put_data)
1630 * Add PUT data, leaving previously set PUT data unchanged.
1631 * Affects only PUT requests.
1633 * Expects a string as parameter containing the data to concatenate.
1635 * Returns TRUE on success, or FALSE on failure.
1637 PHP_METHOD(HttpRequest
, addPutData
)
1642 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &put_data
, &data_len
)) {
1647 zval
*data
= GET_PROP(putData
);
1649 if (Z_STRLEN_P(data
)) {
1650 Z_STRVAL_P(data
) = erealloc(Z_STRVAL_P(data
), (Z_STRLEN_P(data
) += data_len
) + 1);
1651 Z_STRVAL_P(data
)[Z_STRLEN_P(data
)] = '\0';
1652 memcpy(Z_STRVAL_P(data
) + Z_STRLEN_P(data
) - data_len
, put_data
, data_len
);
1654 UPD_STRL(putData
, put_data
, data_len
);
1662 /* {{{ proto string HttpRequest::getPutData()
1664 * Get previously set PUT data.
1666 * Returns a string containing the currently set raw post data.
1668 PHP_METHOD(HttpRequest
, getPutData
)
1672 if (return_value_used
) {
1673 RETURN_PROP(putData
);
1678 /* {{{ proto array HttpRequest::getResponseData()
1680 * Get all response data after the request has been sent.
1682 * Returns an associative array with the key "headers" containing an associative
1683 * array holding all response headers, as well as the key "body" containing a
1684 * string with the response body.
1686 * If redirects were allowed and several responses were received, the data
1687 * references the last received response.
1689 PHP_METHOD(HttpRequest
, getResponseData
)
1693 if (return_value_used
) {
1694 RETURN_PROP(responseData
);
1699 /* {{{ proto mixed HttpRequest::getResponseHeader([string name])
1701 * Get response header(s) after the request has been sent.
1703 * Accepts an string as optional parameter specifying a certain header to read.
1704 * If the parameter is empty or omitted all response headers will be returned.
1706 * Returns either a string with the value of the header matching name if requested,
1707 * FALSE on failure, or an associative array containing all response headers.
1709 * If redirects were allowed and several responses were received, the data
1710 * references the last received response.
1712 PHP_METHOD(HttpRequest
, getResponseHeader
)
1714 if (return_value_used
) {
1715 zval
*data
, **headers
, **header
;
1716 char *header_name
= NULL
;
1719 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &header_name
, &header_len
)) {
1723 data
= GET_PROP(responseData
);
1724 if ( (Z_TYPE_P(data
) == IS_ARRAY
) &&
1725 (SUCCESS
== zend_hash_find(Z_ARRVAL_P(data
), "headers", sizeof("headers"), (void *) &headers
)) &&
1726 (Z_TYPE_PP(headers
) == IS_ARRAY
)) {
1727 if (!header_len
|| !header_name
) {
1728 RETVAL_ZVAL(*headers
, 1, 0);
1729 } else if (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(headers
), pretty_key(header_name
, header_len
, 1, 1), header_len
+ 1, (void *) &header
)) {
1730 RETVAL_ZVAL(*header
, 1, 0);
1741 /* {{{ proto array HttpRequest::getResponseCookies([int flags[, array allowed_extras]])
1743 * Get response cookie(s) after the request has been sent.
1745 * Returns an array of stdClass objects like http_parse_cookie would return.
1747 * If redirects were allowed and several responses were received, the data
1748 * references the last received response.
1750 PHP_METHOD(HttpRequest
, getResponseCookies
)
1752 if (return_value_used
) {
1754 zval
*allowed_extras_array
= NULL
, *data
, **headers
;
1756 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|la", &flags
, &allowed_extras_array
)) {
1760 data
= GET_PROP(responseData
);
1761 if ( (Z_TYPE_P(data
) == IS_ARRAY
) &&
1762 (SUCCESS
== zend_hash_find(Z_ARRVAL_P(data
), "headers", sizeof("headers"), (void *) &headers
)) &&
1763 (Z_TYPE_PP(headers
) == IS_ARRAY
)) {
1766 char *key
= NULL
, **allowed_extras
= NULL
;
1767 zval
**header
= NULL
, **entry
= NULL
;
1768 HashPosition pos
, pos1
, pos2
;
1770 array_init(return_value
);
1772 if (allowed_extras_array
) {
1773 allowed_extras
= ecalloc(zend_hash_num_elements(Z_ARRVAL_P(allowed_extras_array
)) + 1, sizeof(char *));
1774 FOREACH_VAL(pos
, allowed_extras_array
, entry
) {
1775 ZVAL_ADDREF(*entry
);
1776 convert_to_string_ex(entry
);
1777 allowed_extras
[i
++] = estrndup(Z_STRVAL_PP(entry
), Z_STRLEN_PP(entry
));
1778 zval_ptr_dtor(entry
);
1782 FOREACH_HASH_KEYVAL(pos1
, Z_ARRVAL_PP(headers
), key
, idx
, header
) {
1783 if (key
&& !strcasecmp(key
, "Set-Cookie")) {
1784 http_cookie_list list
;
1786 if (Z_TYPE_PP(header
) == IS_ARRAY
) {
1787 zval
**single_header
;
1789 FOREACH_VAL(pos2
, *header
, single_header
) {
1790 ZVAL_ADDREF(*single_header
);
1791 convert_to_string_ex(single_header
);
1792 if (http_parse_cookie_ex(&list
, Z_STRVAL_PP(single_header
), flags
, allowed_extras
)) {
1795 MAKE_STD_ZVAL(cookie
);
1796 object_init(cookie
);
1797 http_cookie_list_tostruct(&list
, cookie
);
1798 add_next_index_zval(return_value
, cookie
);
1799 http_cookie_list_dtor(&list
);
1801 zval_ptr_dtor(single_header
);
1804 ZVAL_ADDREF(*header
);
1805 convert_to_string_ex(header
);
1806 if (http_parse_cookie_ex(&list
, Z_STRVAL_PP(header
), flags
, allowed_extras
)) {
1809 MAKE_STD_ZVAL(cookie
);
1810 object_init(cookie
);
1811 http_cookie_list_tostruct(&list
, cookie
);
1812 add_next_index_zval(return_value
, cookie
);
1813 http_cookie_list_dtor(&list
);
1815 zval_ptr_dtor(header
);
1822 if (allowed_extras
) {
1823 for (i
= 0; allowed_extras
[i
]; ++i
) {
1824 efree(allowed_extras
[i
]);
1826 efree(allowed_extras
);
1835 /* {{{ proto string HttpRequest::getResponseBody()
1837 * Get the response body after the request has been sent.
1839 * Returns a string containing the response body.
1841 * If redirects were allowed and several responses were received, the data
1842 * references the last received response.
1844 PHP_METHOD(HttpRequest
, getResponseBody
)
1848 if (return_value_used
) {
1850 zval
*data
= GET_PROP(responseData
);
1852 if ( (Z_TYPE_P(data
) == IS_ARRAY
) &&
1853 (SUCCESS
== zend_hash_find(Z_ARRVAL_P(data
), "body", sizeof("body"), (void *) &body
))) {
1854 RETURN_ZVAL(*body
, 1, 0);
1862 /* {{{ proto int HttpRequest::getResponseCode()
1864 * Get the response code after the request has been sent.
1866 * Returns an int representing the response code.
1868 * If redirects were allowed and several responses were received, the data
1869 * references the last received response.
1871 PHP_METHOD(HttpRequest
, getResponseCode
)
1875 if (return_value_used
) {
1876 RETURN_PROP(responseCode
);
1881 /* {{{ proto string HttpRequest::getResponseStatus()
1883 * Get the response status (i.e. the string after the response code) after the message has been sent.
1885 * Returns a string containing the response status text.
1887 PHP_METHOD(HttpRequest
, getResponseStatus
)
1891 if (return_value_used
) {
1892 RETURN_PROP(responseStatus
);
1897 /* {{{ proto mixed HttpRequest::getResponseInfo([string name])
1899 * Get response info after the request has been sent.
1900 * See http_get() for a full list of returned info.
1902 * Accepts a string as optional parameter specifying the info to read.
1903 * If the parameter is empty or omitted, an associative array containing
1904 * all available info will be returned.
1906 * Returns either a scalar containing the value of the info matching name if
1907 * requested, FALSE on failure, or an associative array containing all
1910 * If redirects were allowed and several responses were received, the data
1911 * references the last received response.
1913 PHP_METHOD(HttpRequest
, getResponseInfo
)
1915 if (return_value_used
) {
1916 zval
*info
, **infop
;
1917 char *info_name
= NULL
;
1920 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &info_name
, &info_len
)) {
1924 info
= GET_PROP(responseInfo
);
1926 if (Z_TYPE_P(info
) != IS_ARRAY
) {
1930 if (info_len
&& info_name
) {
1931 if (SUCCESS
== zend_hash_find(Z_ARRVAL_P(info
), pretty_key(info_name
, info_len
, 0, 0), info_len
+ 1, (void *) &infop
)) {
1932 RETURN_ZVAL(*infop
, 1, 0);
1934 http_error_ex(HE_NOTICE
, HTTP_E_INVALID_PARAM
, "Could not find response info named %s", info_name
);
1938 RETURN_ZVAL(info
, 1, 0);
1944 /* {{{ proto HttpMessage HttpRequest::getResponseMessage()
1946 * Get the full response as HttpMessage object after the request has been sent.
1948 * Returns an HttpMessage object of the response.
1950 * If redirects were allowed and several responses were received, the data
1951 * references the last received response. Use HttpMessage::getParentMessage()
1952 * to access the data of previously received responses within this request
1955 * Throws HttpException, HttpRuntimeException.
1957 PHP_METHOD(HttpRequest
, getResponseMessage
)
1962 SET_EH_THROW_HTTP();
1963 message
= GET_PROP(responseMessage
);
1964 if (Z_TYPE_P(message
) == IS_OBJECT
) {
1965 RETVAL_OBJECT(message
, 1);
1967 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "HttpRequest does not contain a response message");
1974 /* {{{ proto HttpMessage HttpRequest::getRequestMessage()
1976 * Get sent HTTP message.
1978 * Returns an HttpMessage object representing the sent request.
1980 * If redirects were allowed and several responses were received, the data
1981 * references the last received response. Use HttpMessage::getParentMessage()
1982 * to access the data of previously sent requests within this request
1985 * Note that the internal request message is immutable, that means that the
1986 * request message received through HttpRequest::getRequestMessage() will
1987 * always look the same for the same request, regardless of any changes you
1988 * may have made to the returned object.
1990 * Throws HttpMalformedHeadersException, HttpEncodingException.
1992 PHP_METHOD(HttpRequest
, getRequestMessage
)
1996 if (return_value_used
) {
1998 getObject(http_request_object
, obj
);
2000 SET_EH_THROW_HTTP();
2001 if ((msg
= http_message_parse(PHPSTR_VAL(&obj
->request
->conv
.request
), PHPSTR_LEN(&obj
->request
->conv
.request
)))) {
2002 RETVAL_OBJVAL(http_message_object_new_ex(http_message_object_ce
, msg
, NULL
), 0);
2009 /* {{{ proto string HttpRequest::getRawRequestMessage()
2011 * Get sent HTTP message.
2013 * Returns an HttpMessage in a form of a string
2015 PHP_METHOD(HttpRequest
, getRawRequestMessage
)
2019 if (return_value_used
) {
2020 getObject(http_request_object
, obj
);
2022 RETURN_PHPSTR_DUP(&obj
->request
->conv
.request
);
2027 /* {{{ proto string HttpRequest::getRawResponseMessage()
2029 * Get the entire HTTP response.
2031 * Returns the complete web server response, including the headers in a form of a string.
2033 PHP_METHOD(HttpRequest
, getRawResponseMessage
)
2037 if (return_value_used
) {
2038 getObject(http_request_object
, obj
);
2040 RETURN_PHPSTR_DUP(&obj
->request
->conv
.response
);
2045 /* {{{ proto HttpMessage HttpRequest::getHistory()
2047 * Get all sent requests and received responses as an HttpMessage object.
2049 * If you want to record history, set the instance variable
2050 * HttpRequest::$recordHistory to TRUE.
2052 * Returns an HttpMessage object representing the complete request/response
2055 * The object references the last received response, use HttpMessage::getParentMessage()
2056 * to access the data of previously sent requests and received responses.
2058 * Throws HttpRuntimeException.
2060 PHP_METHOD(HttpRequest
, getHistory
)
2064 if (return_value_used
) {
2067 SET_EH_THROW_HTTP();
2068 hist
= GET_PROP(history
);
2069 if (Z_TYPE_P(hist
) == IS_OBJECT
) {
2070 RETVAL_OBJECT(hist
, 1);
2072 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "The history is empty");
2079 /* {{{ proto void HttpRequest::clearHistory()
2081 * Clear the history.
2083 PHP_METHOD(HttpRequest
, clearHistory
)
2088 MAKE_STD_ZVAL(hist
);
2090 SET_PROP(history
, hist
);
2091 zval_ptr_dtor(&hist
);
2096 /* {{{ proto HttpMessage HttpRequest::send()
2098 * Send the HTTP request.
2100 * Returns the received response as HttpMessage object.
2102 * NOTE: While an exception may be thrown, the transfer could have succeeded
2103 * at least partially, so you might want to check the return values of various
2104 * HttpRequest::getResponse*() methods.
2106 * Throws HttpRuntimeException, HttpRequestException,
2107 * HttpMalformedHeaderException, HttpEncodingException.
2112 * $r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
2113 * $r->setOptions(array('lastmodified' => filemtime('local.rss')));
2114 * $r->addQueryData(array('category' => 3));
2117 * if ($r->getResponseCode() == 200) {
2118 * file_put_contents('local.rss', $r->getResponseBody());
2120 * } catch (HttpException $ex) {
2129 * $r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
2130 * $r->setOptions(array('cookies' => array('lang' => 'de')));
2131 * $r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
2132 * $r->addPostFile('image', 'profile.jpg', 'image/jpeg');
2134 * echo $r->send()->getBody();
2135 * } catch (HttpException $ex) {
2141 PHP_METHOD(HttpRequest
, send
)
2143 getObject(http_request_object
, obj
);
2147 SET_EH_THROW_HTTP();
2152 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Cannot perform HttpRequest::send() while attached to an HttpRequestPool");
2153 } else if (SUCCESS
== http_request_object_requesthandler(obj
, getThis())) {
2154 http_request_exec(obj
->request
);
2155 if (SUCCESS
== http_request_object_responsehandler(obj
, getThis())) {
2156 RETVAL_OBJECT(GET_PROP(responseMessage
), 1);
2164 #endif /* ZEND_ENGINE_2 && HTTP_HAVE_CURL */
2171 * vim600: noet sw=4 ts=4 fdm=marker
2172 * vim<600: noet sw=4 ts=4