1 #include "php_http_api.h"
2 #include "php_http_client.h"
4 #include <ext/spl/spl_observer.h>
7 * array of name => php_http_client_driver_t*
9 static HashTable php_http_client_drivers
;
11 PHP_HTTP_API STATUS
php_http_client_driver_add(php_http_client_driver_t
*driver
)
13 return zend_hash_add(&php_http_client_drivers
, driver
->name_str
, driver
->name_len
+ 1, (void *) driver
, sizeof(php_http_client_driver_t
), NULL
);
16 PHP_HTTP_API STATUS
php_http_client_driver_get(const char *name_str
, size_t name_len
, php_http_client_driver_t
*driver
)
18 php_http_client_driver_t
*tmp
;
20 if ((name_str
&& SUCCESS
== zend_hash_find(&php_http_client_drivers
, name_str
, name_len
+ 1, (void *) &tmp
))
21 || (SUCCESS
== zend_hash_get_current_data(&php_http_client_drivers
, (void *) &tmp
))) {
28 static int apply_driver_list(void *p
, void *arg TSRMLS_DC
)
30 php_http_client_driver_t
*d
= p
;
34 ZVAL_STRINGL(zname
, d
->name_str
, d
->name_len
, 1);
36 zend_hash_next_index_insert(arg
, &zname
, sizeof(zval
*), NULL
);
37 return ZEND_HASH_APPLY_KEEP
;
40 PHP_HTTP_API
void php_http_client_driver_list(HashTable
*ht TSRMLS_DC
)
42 zend_hash_apply_with_argument(&php_http_client_drivers
, apply_driver_list
, ht TSRMLS_CC
);
45 void php_http_client_options_set_subr(zval
*this_ptr
, char *key
, size_t len
, zval
*opts
, int overwrite TSRMLS_DC
)
47 if (overwrite
|| (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
)))) {
48 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
49 zval
*old_opts
, *new_opts
, **entry
= NULL
;
51 MAKE_STD_ZVAL(new_opts
);
53 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
54 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
55 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL_P(new_opts
));
59 if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
61 zend_symtable_update(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &opts
, sizeof(zval
*), NULL
);
63 zend_symtable_del(Z_ARRVAL_P(new_opts
), key
, len
);
65 } else if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
66 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &entry
)) {
67 array_join(Z_ARRVAL_P(opts
), Z_ARRVAL_PP(entry
), 0, 0);
70 zend_symtable_update(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &opts
, sizeof(zval
*), NULL
);
74 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
75 zval_ptr_dtor(&new_opts
);
79 void php_http_client_options_set(zval
*this_ptr
, zval
*opts TSRMLS_DC
)
81 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
84 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
85 zend_bool is_client
= instanceof_function(this_ce
, php_http_client_class_entry TSRMLS_CC
);
87 MAKE_STD_ZVAL(new_opts
);
90 if (!opts
|| !zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
91 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
92 zval_ptr_dtor(&new_opts
);
94 zval
*old_opts
, *add_opts
, **opt
;
96 MAKE_STD_ZVAL(add_opts
);
98 /* some options need extra attention -- thus cannot use array_merge() directly */
99 FOREACH_KEYVAL(pos
, opts
, key
, opt
) {
100 if (key
.type
== HASH_KEY_IS_STRING
) {
101 #define KEYMATCH(k, s) ((sizeof(s)==k.len) && !strcasecmp(k.str, s))
102 if (Z_TYPE_PP(opt
) == IS_ARRAY
&& (KEYMATCH(key
, "ssl") || KEYMATCH(key
, "cookies"))) {
103 php_http_client_options_set_subr(getThis(), key
.str
, key
.len
, *opt
, 0 TSRMLS_CC
);
104 } else if (is_client
&& (KEYMATCH(key
, "recordHistory") || KEYMATCH(key
, "responseMessageClass"))) {
105 zend_update_property(this_ce
, getThis(), key
.str
, key
.len
-1, *opt TSRMLS_CC
);
106 } else if (Z_TYPE_PP(opt
) == IS_NULL
) {
107 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
108 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
109 zend_symtable_del(Z_ARRVAL_P(old_opts
), key
.str
, key
.len
);
113 add_assoc_zval_ex(add_opts
, key
.str
, key
.len
, *opt
);
118 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
119 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
120 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL_P(new_opts
));
122 array_join(Z_ARRVAL_P(add_opts
), Z_ARRVAL_P(new_opts
), 0, 0);
123 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
124 zval_ptr_dtor(&new_opts
);
125 zval_ptr_dtor(&add_opts
);
129 void php_http_client_options_get_subr(zval
*this_ptr
, char *key
, size_t len
, zval
*return_value TSRMLS_DC
)
131 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
132 zval
**options
, *opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
134 if ((Z_TYPE_P(opts
) == IS_ARRAY
) && (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(opts
), key
, len
, (void *) &options
))) {
135 RETVAL_ZVAL(*options
, 1, 0);
139 static void queue_dtor(void *enqueued
)
141 php_http_client_enqueue_t
*e
= enqueued
;
148 PHP_HTTP_API php_http_client_t
*php_http_client_init(php_http_client_t
*h
, php_http_client_ops_t
*ops
, php_resource_factory_t
*rf
, void *init_arg TSRMLS_DC
)
150 php_http_client_t
*free_h
= NULL
;
153 free_h
= h
= emalloc(sizeof(*h
));
155 memset(h
, 0, sizeof(*h
));
160 } else if (ops
->rsrc
) {
161 h
->rf
= php_resource_factory_init(NULL
, h
->ops
->rsrc
, h
, NULL
);
163 zend_llist_init(&h
->requests
, sizeof(php_http_client_enqueue_t
), queue_dtor
, 0);
164 zend_llist_init(&h
->responses
, sizeof(void *), NULL
, 0);
165 TSRMLS_SET_CTX(h
->ts
);
168 if (!(h
= h
->ops
->init(h
, init_arg
))) {
169 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Could not initialize client");
179 PHP_HTTP_API php_http_client_t
*php_http_client_copy(php_http_client_t
*from
, php_http_client_t
*to
)
181 if (from
->ops
->copy
) {
182 return from
->ops
->copy(from
, to
);
188 PHP_HTTP_API
void php_http_client_dtor(php_http_client_t
*h
)
194 zend_llist_clean(&h
->requests
);
195 zend_llist_clean(&h
->responses
);
197 php_resource_factory_free(&h
->rf
);
200 PHP_HTTP_API
void php_http_client_free(php_http_client_t
**h
) {
202 php_http_client_dtor(*h
);
208 PHP_HTTP_API STATUS
php_http_client_enqueue(php_http_client_t
*h
, php_http_client_enqueue_t
*enqueue
)
210 TSRMLS_FETCH_FROM_CTX(h
->ts
);
212 if (h
->ops
->enqueue
) {
213 if (php_http_client_enqueued(h
, enqueue
->request
, NULL
)) {
214 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to enqueue request; request already in queue");
217 return h
->ops
->enqueue(h
, enqueue
);
223 PHP_HTTP_API STATUS
php_http_client_dequeue(php_http_client_t
*h
, php_http_message_t
*request
)
225 TSRMLS_FETCH_FROM_CTX(h
->ts
);
227 if (h
->ops
->dequeue
) {
228 php_http_client_enqueue_t
*enqueue
= php_http_client_enqueued(h
, request
, NULL
);
231 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to dequeue request; request not in queue");
234 return h
->ops
->dequeue(h
, enqueue
);
239 PHP_HTTP_API php_http_client_enqueue_t
*php_http_client_enqueued(php_http_client_t
*h
, void *compare_arg
, php_http_client_enqueue_cmp_func_t compare_func
)
241 zend_llist_element
*el
= NULL
;
244 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
245 if (compare_func((php_http_client_enqueue_t
*) el
->data
, compare_arg
)) {
250 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
251 if (((php_http_client_enqueue_t
*) el
->data
)->request
== compare_arg
) {
256 return el
? (php_http_client_enqueue_t
*) el
->data
: NULL
;
259 PHP_HTTP_API STATUS
php_http_client_wait(php_http_client_t
*h
, struct timeval
*custom_timeout
)
262 return h
->ops
->wait(h
, custom_timeout
);
268 PHP_HTTP_API
int php_http_client_once(php_http_client_t
*h
)
271 return h
->ops
->once(h
);
277 PHP_HTTP_API STATUS
php_http_client_exec(php_http_client_t
*h
)
280 return h
->ops
->exec(h
);
286 PHP_HTTP_API
void php_http_client_reset(php_http_client_t
*h
)
292 zend_llist_clean(&h
->requests
);
293 zend_llist_clean(&h
->responses
);
296 PHP_HTTP_API STATUS
php_http_client_setopt(php_http_client_t
*h
, php_http_client_setopt_opt_t opt
, void *arg
)
298 if (h
->ops
->setopt
) {
299 return h
->ops
->setopt(h
, opt
, arg
);
305 PHP_HTTP_API STATUS
php_http_client_getopt(php_http_client_t
*h
, php_http_client_getopt_opt_t opt
, void *arg
, void *res_ptr
)
307 if (h
->ops
->getopt
) {
308 return h
->ops
->getopt(h
, opt
, arg
, res_ptr
);
313 zend_class_entry
*php_http_client_class_entry
;
314 static zend_object_handlers php_http_client_object_handlers
;
316 void php_http_client_object_free(void *object TSRMLS_DC
)
318 php_http_client_object_t
*o
= (php_http_client_object_t
*) object
;
320 php_http_client_free(&o
->client
);
321 zend_object_std_dtor((zend_object
*) o TSRMLS_CC
);
325 zend_object_value
php_http_client_object_new_ex(zend_class_entry
*ce
, php_http_client_t
*client
, php_http_client_object_t
**ptr TSRMLS_DC
)
327 php_http_client_object_t
*o
;
329 o
= ecalloc(1, sizeof(php_http_client_object_t
));
330 zend_object_std_init((zend_object
*) o
, ce TSRMLS_CC
);
331 object_properties_init((zend_object
*) o
, ce
);
339 o
->zv
.handle
= zend_objects_store_put(o
, NULL
, php_http_client_object_free
, NULL TSRMLS_CC
);
340 o
->zv
.handlers
= &php_http_client_object_handlers
;
345 zend_object_value
php_http_client_object_new(zend_class_entry
*ce TSRMLS_DC
)
347 return php_http_client_object_new_ex(ce
, NULL
, NULL TSRMLS_CC
);
350 static void handle_history(zval
*zclient
, php_http_message_t
*request
, php_http_message_t
*response TSRMLS_DC
)
352 zval
*new_hist
, *old_hist
= zend_read_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), 0 TSRMLS_CC
);
353 php_http_message_t
*zipped
= php_http_message_zip(response
, request
);
354 zend_object_value ov
= php_http_message_object_new_ex(php_http_message_get_class_entry(), zipped
, NULL TSRMLS_CC
);
356 MAKE_STD_ZVAL(new_hist
);
357 ZVAL_OBJVAL(new_hist
, ov
, 0);
359 if (Z_TYPE_P(old_hist
) == IS_OBJECT
) {
360 php_http_message_object_prepend(new_hist
, old_hist
, 1 TSRMLS_CC
);
363 zend_update_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), new_hist TSRMLS_CC
);
364 zval_ptr_dtor(&new_hist
);
367 static STATUS
handle_response(void *arg
, php_http_client_t
*client
, php_http_client_enqueue_t
*e
, php_http_message_t
**request
, php_http_message_t
**response
)
370 php_http_message_t
*msg
;
371 php_http_client_progress_state_t
*progress
;
372 TSRMLS_FETCH_FROM_CTX(client
->ts
);
374 INIT_PZVAL(&zclient
);
375 ZVAL_OBJVAL(&zclient
, ((php_http_client_object_t
*) arg
)->zv
, 0);
377 if ((msg
= *response
)) {
378 php_http_message_object_t
*msg_obj
;
379 zval
*info
, *zresponse
, *zrequest
;
381 if (i_zend_is_true(zend_read_property(php_http_client_class_entry
, &zclient
, ZEND_STRL("recordHistory"), 0 TSRMLS_CC
))) {
382 handle_history(&zclient
, *request
, *response TSRMLS_CC
);
385 /* hard detach, redirects etc. are in the history */
386 php_http_message_free(&msg
->parent
);
389 MAKE_STD_ZVAL(zresponse
);
390 ZVAL_OBJVAL(zresponse
, php_http_message_object_new_ex(php_http_client_response_get_class_entry(), msg
, &msg_obj TSRMLS_CC
), 0);
392 MAKE_STD_ZVAL(zrequest
);
393 ZVAL_OBJVAL(zrequest
, ((php_http_message_object_t
*) e
->opaque
)->zv
, 1);
395 php_http_message_object_prepend(zresponse
, zrequest
, 1 TSRMLS_CC
);
399 php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, e
->request
, &Z_ARRVAL_P(info
));
400 zend_update_property(php_http_client_response_get_class_entry(), zresponse
, ZEND_STRL("transferInfo"), info TSRMLS_CC
);
401 zval_ptr_dtor(&info
);
403 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
404 zend_llist_add_element(&client
->responses
, &msg_obj
);
406 if (e
->closure
.fci
.size
) {
409 zend_fcall_info_argn(&e
->closure
.fci TSRMLS_CC
, 1, &zresponse
);
410 with_error_handling(EH_NORMAL
, NULL
) {
411 zend_fcall_info_call(&e
->closure
.fci
, &e
->closure
.fcc
, &retval
, NULL TSRMLS_CC
);
412 } end_error_handling();
413 zend_fcall_info_argn(&e
->closure
.fci TSRMLS_CC
, 0);
416 if (Z_TYPE_P(retval
) == IS_BOOL
&& Z_BVAL_P(retval
)) {
417 php_http_client_dequeue(client
, e
->request
);
419 zval_ptr_dtor(&retval
);
423 zval_ptr_dtor(&zresponse
);
424 zval_ptr_dtor(&zrequest
);
427 if (SUCCESS
== php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, e
->request
, &progress
)) {
428 progress
->info
= "finished";
429 progress
->finished
= 1;
430 client
->callback
.progress
.func(client
->callback
.progress
.arg
, client
, e
, progress
);
436 static void handle_progress(void *arg
, php_http_client_t
*client
, php_http_client_enqueue_t
*e
, php_http_client_progress_state_t
*progress
)
438 zval
*zrequest
, *zprogress
, *retval
= NULL
, *zclient
;
439 TSRMLS_FETCH_FROM_CTX(client
->ts
);
441 MAKE_STD_ZVAL(zclient
);
442 ZVAL_OBJVAL(zclient
, ((php_http_client_object_t
*) arg
)->zv
, 1);
443 MAKE_STD_ZVAL(zrequest
);
444 ZVAL_OBJVAL(zrequest
, ((php_http_message_object_t
*) e
->opaque
)->zv
, 1);
445 MAKE_STD_ZVAL(zprogress
);
446 object_init(zprogress
);
447 add_property_bool(zprogress
, "started", progress
->started
);
448 add_property_bool(zprogress
, "finished", progress
->finished
);
449 add_property_string(zprogress
, "info", STR_PTR(progress
->info
), 1);
450 add_property_double(zprogress
, "dltotal", progress
->dl
.total
);
451 add_property_double(zprogress
, "dlnow", progress
->dl
.now
);
452 add_property_double(zprogress
, "ultotal", progress
->ul
.total
);
453 add_property_double(zprogress
, "ulnow", progress
->ul
.now
);
454 with_error_handling(EH_NORMAL
, NULL
) {
455 zend_call_method_with_2_params(&zclient
, NULL
, NULL
, "notify", &retval
, zrequest
, zprogress
);
456 } end_error_handling();
457 zval_ptr_dtor(&zclient
);
458 zval_ptr_dtor(&zrequest
);
459 zval_ptr_dtor(&zprogress
);
461 zval_ptr_dtor(&retval
);
465 static void response_dtor(void *data
)
467 php_http_message_object_t
*msg_obj
= *(php_http_message_object_t
**) data
;
468 TSRMLS_FETCH_FROM_CTX(msg_obj
->message
->ts
);
470 zend_objects_store_del_ref_by_handle_ex(msg_obj
->zv
.handle
, msg_obj
->zv
.handlers TSRMLS_CC
);
473 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_construct
, 0, 0, 0)
474 ZEND_ARG_INFO(0, driver
)
475 ZEND_ARG_INFO(0, persistent_handle_id
)
477 static PHP_METHOD(HttpClient
, __construct
)
479 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
480 char *driver_str
= NULL
, *persistent_handle_str
= NULL
;
481 int driver_len
= 0, persistent_handle_len
= 0;
483 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|ss", &driver_str
, &driver_len
, &persistent_handle_str
, &persistent_handle_len
)) {
484 php_http_client_driver_t driver
;
486 if (SUCCESS
== php_http_client_driver_get(driver_str
, driver_len
, &driver
)) {
487 php_resource_factory_t
*rf
= NULL
;
488 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
492 object_init_ex(os
, spl_ce_SplObjectStorage
);
493 zend_update_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), os TSRMLS_CC
);
496 if (persistent_handle_len
) {
499 php_persistent_handle_factory_t
*pf
;
501 name_len
= spprintf(&name_str
, 0, "http\\Client\\%s", driver
.name_str
);
502 php_http_pretty_key(name_str
+ sizeof("http\\Client"), driver
.name_len
, 1, 1);
504 if ((pf
= php_persistent_handle_concede(NULL
, name_str
, name_len
, persistent_handle_str
, persistent_handle_len
, NULL
, NULL TSRMLS_CC
))) {
505 rf
= php_resource_factory_init(NULL
, php_persistent_handle_get_resource_factory_ops(), pf
, (void (*)(void *)) php_persistent_handle_abandon
);
511 if ((obj
->client
= php_http_client_init(NULL
, driver
.client_ops
, rf
, NULL TSRMLS_CC
))) {
512 obj
->client
->callback
.response
.func
= handle_response
;
513 obj
->client
->callback
.response
.arg
= obj
;
514 obj
->client
->callback
.progress
.func
= handle_progress
;
515 obj
->client
->callback
.progress
.arg
= obj
;
517 obj
->client
->responses
.dtor
= response_dtor
;
520 php_http_error(HE_WARNING
, PHP_HTTP_E_REQUEST_FACTORY
, "Failed to locate \"%s\" client request handler", driver_str
);
523 } end_error_handling();
526 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_reset
, 0, 0, 0)
528 static PHP_METHOD(HttpClient
, reset
)
530 if (SUCCESS
== zend_parse_parameters_none()) {
531 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
534 php_http_client_reset(obj
->client
);
536 RETVAL_ZVAL(getThis(), 1, 0);
539 static HashTable
*combined_options(zval
*client
, zval
*request TSRMLS_DC
)
543 zval
*z_roptions
= NULL
, *z_coptions
= zend_read_property(php_http_client_class_entry
, client
, ZEND_STRL("options"), 0 TSRMLS_CC
);
545 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
546 num_options
= zend_hash_num_elements(Z_ARRVAL_P(z_coptions
));
548 zend_call_method_with_0_params(&request
, NULL
, NULL
, "getOptions", &z_roptions
);
549 if (z_roptions
&& Z_TYPE_P(z_roptions
) == IS_ARRAY
) {
550 int num
= zend_hash_num_elements(Z_ARRVAL_P(z_roptions
));
551 if (num
> num_options
) {
555 ALLOC_HASHTABLE(options
);
556 ZEND_INIT_SYMTABLE_EX(options
, num_options
, 0);
557 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
558 array_copy(Z_ARRVAL_P(z_coptions
), options
);
561 if (Z_TYPE_P(z_roptions
) == IS_ARRAY
) {
562 array_join(Z_ARRVAL_P(z_roptions
), options
, 0, 0);
564 zval_ptr_dtor(&z_roptions
);
569 static void msg_queue_dtor(php_http_client_enqueue_t
*e
)
571 php_http_message_object_t
*msg_obj
= e
->opaque
;
572 TSRMLS_FETCH_FROM_CTX(msg_obj
->message
->ts
);
574 zend_objects_store_del_ref_by_handle_ex(msg_obj
->zv
.handle
, msg_obj
->zv
.handlers TSRMLS_CC
);
575 zend_hash_destroy(e
->options
);
576 FREE_HASHTABLE(e
->options
);
578 if (e
->closure
.fci
.size
) {
579 zval_ptr_dtor(&e
->closure
.fci
.function_name
);
580 if (e
->closure
.fci
.object_ptr
) {
581 zval_ptr_dtor(&e
->closure
.fci
.object_ptr
);
586 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enqueue
, 0, 0, 1)
587 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
588 ZEND_ARG_INFO(0, callable
)
590 static PHP_METHOD(HttpClient
, enqueue
)
592 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
594 zend_fcall_info fci
= empty_fcall_info
;
595 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
597 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O|f", &request
, php_http_client_request_get_class_entry(), &fci
, &fcc
)) {
598 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
599 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
601 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
602 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to enqueue request; request already in queue");
604 php_http_client_enqueue_t q
= {
606 combined_options(getThis(), request TSRMLS_CC
),
613 Z_ADDREF_P(fci
.function_name
);
614 if (fci
.object_ptr
) {
615 Z_ADDREF_P(fci
.object_ptr
);
619 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
620 php_http_client_enqueue(obj
->client
, &q
);
623 } end_error_handling();
625 RETVAL_ZVAL(getThis(), 1, 0);
628 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_dequeue
, 0, 0, 1)
629 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
631 static PHP_METHOD(HttpClient
, dequeue
)
633 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
636 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_get_class_entry())) {
637 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
638 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
640 php_http_client_dequeue(obj
->client
, msg_obj
->message
);
642 } end_error_handling();
644 RETVAL_ZVAL(getThis(), 1, 0);
647 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_requeue
, 0, 0, 1)
648 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
649 ZEND_ARG_INFO(0, callable
)
651 static PHP_METHOD(HttpClient
, requeue
)
653 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
655 zend_fcall_info fci
= empty_fcall_info
;
656 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
658 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O|f", &request
, php_http_client_request_get_class_entry(), &fci
, &fcc
)) {
659 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
660 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
661 php_http_client_enqueue_t q
= {
663 combined_options(getThis(), request TSRMLS_CC
),
670 Z_ADDREF_P(fci
.function_name
);
671 if (fci
.object_ptr
) {
672 Z_ADDREF_P(fci
.object_ptr
);
676 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
677 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
678 php_http_client_dequeue(obj
->client
, msg_obj
->message
);
680 php_http_client_enqueue(obj
->client
, &q
);
682 } end_error_handling();
684 RETVAL_ZVAL(getThis(), 1, 0);
687 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getResponse
, 0, 0, 0)
688 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
690 static PHP_METHOD(HttpClient
, getResponse
)
692 zval
*zrequest
= NULL
;
694 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|O", &zrequest
, php_http_client_request_get_class_entry())) {
695 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
698 /* pop off the last respone */
699 if (obj
->client
->responses
.tail
) {
700 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) obj
->client
->responses
.tail
->data
;
704 RETVAL_OBJVAL(response_obj
->zv
, 1);
705 zend_llist_remove_tail(&obj
->client
->responses
);
709 /* lookup the response with the request */
710 zend_llist_element
*el
= NULL
;
711 php_http_message_object_t
*req_obj
= zend_object_store_get_object(zrequest TSRMLS_CC
);
713 for (el
= obj
->client
->responses
.head
; el
; el
= el
->next
) {
714 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) el
->data
;
716 if (response_obj
->message
->parent
== req_obj
->message
) {
717 RETVAL_OBJVAL(response_obj
->zv
, 1);
725 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getHistory
, 0, 0, 0)
727 static PHP_METHOD(HttpClient
, getHistory
)
729 if (SUCCESS
== zend_parse_parameters_none()) {
730 zval
*zhistory
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("history"), 0 TSRMLS_CC
);
731 RETVAL_ZVAL(zhistory
, 1, 0);
735 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_send
, 0, 0, 0)
737 static PHP_METHOD(HttpClient
, send
)
741 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
742 if (SUCCESS
== zend_parse_parameters_none()) {
743 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
744 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
746 php_http_client_exec(obj
->client
);
747 } end_error_handling();
749 } end_error_handling();
751 RETVAL_ZVAL(getThis(), 1, 0);
754 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_once
, 0, 0, 0)
756 static PHP_METHOD(HttpClient
, once
)
758 if (SUCCESS
== zend_parse_parameters_none()) {
759 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
761 if (0 < php_http_client_once(obj
->client
)) {
768 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_wait
, 0, 0, 0)
769 ZEND_ARG_INFO(0, timeout
)
771 static PHP_METHOD(HttpClient
, wait
)
775 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|d", &timeout
)) {
776 struct timeval timeout_val
;
777 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
779 timeout_val
.tv_sec
= (time_t) timeout
;
780 timeout_val
.tv_usec
= PHP_HTTP_USEC(timeout
) % PHP_HTTP_MCROSEC
;
782 RETURN_SUCCESS(php_http_client_wait(obj
->client
, timeout
> 0 ? &timeout_val
: NULL
));
787 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enablePipelining
, 0, 0, 0)
788 ZEND_ARG_INFO(0, enable
)
790 static PHP_METHOD(HttpClient
, enablePipelining
)
792 zend_bool enable
= 1;
794 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &enable
)) {
795 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
797 php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING
, &enable
);
799 RETVAL_ZVAL(getThis(), 1, 0);
802 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enableEvents
, 0, 0, 0)
803 ZEND_ARG_INFO(0, enable
)
805 static PHP_METHOD(HttpClient
, enableEvents
)
807 zend_bool enable
= 1;
809 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &enable
)) {
810 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
812 php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_USE_EVENTS
, &enable
);
814 RETVAL_ZVAL(getThis(), 1, 0);
817 static int notify(zend_object_iterator
*iter
, void *puser TSRMLS_DC
)
819 zval
**observer
= NULL
, ***args
= puser
;
821 iter
->funcs
->get_current_data(iter
, &observer TSRMLS_CC
);
823 return php_http_method_call(*observer
, ZEND_STRL("update"), args
[2]?3:args
[1]?2:args
[0]?1:0, args
, NULL TSRMLS_CC
);
828 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify
, 0, 0, 0)
829 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
831 static PHP_METHOD(HttpClient
, notify
)
833 zval
*request
= NULL
, *zprogress
= NULL
;
835 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|O!o!", &request
, php_http_client_request_get_class_entry(), &zprogress
)) {
836 zval
**args
[3], *observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
838 if (Z_TYPE_P(observers
) == IS_OBJECT
) {
839 Z_ADDREF_P(getThis());
840 args
[0] = &getThis();
846 Z_ADDREF_P(zprogress
);
848 args
[2] = &zprogress
;
849 spl_iterator_apply(observers
, notify
, args TSRMLS_CC
);
850 zval_ptr_dtor(&getThis());
852 zval_ptr_dtor(&request
);
855 zval_ptr_dtor(&zprogress
);
860 RETVAL_ZVAL(getThis(), 1, 0);
863 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach
, 0, 0, 1)
864 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
866 static PHP_METHOD(HttpClient
, attach
)
870 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &observer
, spl_ce_SplObserver
)) {
871 zval
*retval
= NULL
, *observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
872 zend_call_method_with_1_params(&observers
, NULL
, NULL
, "attach", &retval
, observer
);
874 zval_ptr_dtor(&retval
);
878 RETVAL_ZVAL(getThis(), 1, 0);
881 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach
, 0, 0, 1)
882 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
884 static PHP_METHOD(HttpClient
, detach
)
888 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &observer
, spl_ce_SplObserver
)) {
889 zval
*retval
, *observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
890 zend_call_method_with_1_params(&observers
, NULL
, NULL
, "detach", &retval
, observer
);
891 zval_ptr_dtor(&retval
);
894 RETVAL_ZVAL(getThis(), 1, 0);
897 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getObservers
, 0, 0, 0)
899 static PHP_METHOD(HttpClient
, getObservers
)
901 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
902 if (SUCCESS
== zend_parse_parameters_none()) {
903 zval
*observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
904 RETVAL_ZVAL(observers
, 1, 0);
906 } end_error_handling();
909 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getProgressInfo
, 0, 0, 1)
910 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
912 static PHP_METHOD(HttpClient
, getProgressInfo
)
916 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
917 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_get_class_entry())) {
918 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
919 php_http_message_object_t
*req_obj
= zend_object_store_get_object(request TSRMLS_CC
);
920 php_http_client_progress_state_t
*progress
;
922 if (SUCCESS
== php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, req_obj
->message
, &progress
)) {
923 object_init(return_value
);
924 add_property_bool(return_value
, "started", progress
->started
);
925 add_property_bool(return_value
, "finished", progress
->finished
);
926 add_property_string(return_value
, "info", STR_PTR(progress
->info
), 1);
927 add_property_double(return_value
, "dltotal", progress
->dl
.total
);
928 add_property_double(return_value
, "dlnow", progress
->dl
.now
);
929 add_property_double(return_value
, "ultotal", progress
->ul
.total
);
930 add_property_double(return_value
, "ulnow", progress
->ul
.now
);
933 } end_error_handling();
936 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getTransferInfo
, 0, 0, 1)
937 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
939 static PHP_METHOD(HttpClient
, getTransferInfo
)
943 with_error_handling(EH_THROW
, php_http_exception_get_class_entry()) {
944 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_get_class_entry())) {
945 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
946 php_http_message_object_t
*req_obj
= zend_object_store_get_object(request TSRMLS_CC
);
948 array_init(return_value
);
949 php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, req_obj
->message
, &Z_ARRVAL_P(return_value
));
951 } end_error_handling();
954 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setOptions
, 0, 0, 0)
955 ZEND_ARG_ARRAY_INFO(0, options
, 1)
957 static PHP_METHOD(HttpClient
, setOptions
)
961 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
962 php_http_client_options_set(getThis(), opts TSRMLS_CC
);
964 RETVAL_ZVAL(getThis(), 1, 0);
968 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getOptions
, 0, 0, 0)
970 static PHP_METHOD(HttpClient
, getOptions
)
972 if (SUCCESS
== zend_parse_parameters_none()) {
973 zval
*options
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
974 RETVAL_ZVAL(options
, 1, 0);
978 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setSslOptions
, 0, 0, 0)
979 ZEND_ARG_ARRAY_INFO(0, ssl_option
, 1)
981 static PHP_METHOD(HttpClient
, setSslOptions
)
985 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
986 php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts
, 1 TSRMLS_CC
);
988 RETVAL_ZVAL(getThis(), 1, 0);
992 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addSslOptions
, 0, 0, 0)
993 ZEND_ARG_ARRAY_INFO(0, ssl_options
, 1)
995 static PHP_METHOD(HttpClient
, addSslOptions
)
999 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1000 php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts
, 0 TSRMLS_CC
);
1002 RETVAL_ZVAL(getThis(), 1, 0);
1006 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getSslOptions
, 0, 0, 0)
1007 ZEND_END_ARG_INFO();
1008 static PHP_METHOD(HttpClient
, getSslOptions
)
1010 if (SUCCESS
== zend_parse_parameters_none()) {
1011 php_http_client_options_get_subr(getThis(), ZEND_STRS("ssl"), return_value TSRMLS_CC
);
1015 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setCookies
, 0, 0, 0)
1016 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1017 ZEND_END_ARG_INFO();
1018 static PHP_METHOD(HttpClient
, setCookies
)
1022 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1023 php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts
, 1 TSRMLS_CC
);
1025 RETVAL_ZVAL(getThis(), 1, 0);
1029 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addCookies
, 0, 0, 0)
1030 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1031 ZEND_END_ARG_INFO();
1032 static PHP_METHOD(HttpClient
, addCookies
)
1036 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1037 php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts
, 0 TSRMLS_CC
);
1039 RETVAL_ZVAL(getThis(), 1, 0);
1043 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getCookies
, 0, 0, 0)
1044 ZEND_END_ARG_INFO();
1045 static PHP_METHOD(HttpClient
, getCookies
)
1047 if (SUCCESS
== zend_parse_parameters_none()) {
1048 php_http_client_options_get_subr(getThis(), ZEND_STRS("cookies"), return_value TSRMLS_CC
);
1052 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableDrivers
, 0, 0, 0)
1053 ZEND_END_ARG_INFO();
1054 static PHP_METHOD(HttpClient
, getAvailableDrivers
) {
1055 if (SUCCESS
== zend_parse_parameters_none()) {
1056 array_init(return_value
);
1057 php_http_client_driver_list(Z_ARRVAL_P(return_value
) TSRMLS_CC
);
1061 static zend_function_entry php_http_client_methods
[] = {
1062 PHP_ME(HttpClient
, __construct
, ai_HttpClient_construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
1063 PHP_ME(HttpClient
, reset
, ai_HttpClient_reset
, ZEND_ACC_PUBLIC
)
1064 PHP_ME(HttpClient
, enqueue
, ai_HttpClient_enqueue
, ZEND_ACC_PUBLIC
)
1065 PHP_ME(HttpClient
, dequeue
, ai_HttpClient_dequeue
, ZEND_ACC_PUBLIC
)
1066 PHP_ME(HttpClient
, requeue
, ai_HttpClient_requeue
, ZEND_ACC_PUBLIC
)
1067 PHP_ME(HttpClient
, send
, ai_HttpClient_send
, ZEND_ACC_PUBLIC
)
1068 PHP_ME(HttpClient
, once
, ai_HttpClient_once
, ZEND_ACC_PUBLIC
)
1069 PHP_ME(HttpClient
, wait
, ai_HttpClient_wait
, ZEND_ACC_PUBLIC
)
1070 PHP_ME(HttpClient
, getResponse
, ai_HttpClient_getResponse
, ZEND_ACC_PUBLIC
)
1071 PHP_ME(HttpClient
, getHistory
, ai_HttpClient_getHistory
, ZEND_ACC_PUBLIC
)
1072 PHP_ME(HttpClient
, enablePipelining
, ai_HttpClient_enablePipelining
, ZEND_ACC_PUBLIC
)
1073 PHP_ME(HttpClient
, enableEvents
, ai_HttpClient_enableEvents
, ZEND_ACC_PUBLIC
)
1074 PHP_ME(HttpClient
, notify
, ai_HttpClient_notify
, ZEND_ACC_PUBLIC
)
1075 PHP_ME(HttpClient
, attach
, ai_HttpClient_attach
, ZEND_ACC_PUBLIC
)
1076 PHP_ME(HttpClient
, detach
, ai_HttpClient_detach
, ZEND_ACC_PUBLIC
)
1077 PHP_ME(HttpClient
, getObservers
, ai_HttpClient_getObservers
, ZEND_ACC_PUBLIC
)
1078 PHP_ME(HttpClient
, getProgressInfo
, ai_HttpClient_getProgressInfo
, ZEND_ACC_PUBLIC
)
1079 PHP_ME(HttpClient
, getTransferInfo
, ai_HttpClient_getTransferInfo
, ZEND_ACC_PUBLIC
)
1080 PHP_ME(HttpClient
, setOptions
, ai_HttpClient_setOptions
, ZEND_ACC_PUBLIC
)
1081 PHP_ME(HttpClient
, getOptions
, ai_HttpClient_getOptions
, ZEND_ACC_PUBLIC
)
1082 PHP_ME(HttpClient
, setSslOptions
, ai_HttpClient_setSslOptions
, ZEND_ACC_PUBLIC
)
1083 PHP_ME(HttpClient
, addSslOptions
, ai_HttpClient_addSslOptions
, ZEND_ACC_PUBLIC
)
1084 PHP_ME(HttpClient
, getSslOptions
, ai_HttpClient_getSslOptions
, ZEND_ACC_PUBLIC
)
1085 PHP_ME(HttpClient
, setCookies
, ai_HttpClient_setCookies
, ZEND_ACC_PUBLIC
)
1086 PHP_ME(HttpClient
, addCookies
, ai_HttpClient_addCookies
, ZEND_ACC_PUBLIC
)
1087 PHP_ME(HttpClient
, getCookies
, ai_HttpClient_getCookies
, ZEND_ACC_PUBLIC
)
1088 PHP_ME(HttpClient
, getAvailableDrivers
, ai_HttpClient_getAvailableDrivers
, ZEND_ACC_PUBLIC
|ZEND_ACC_STATIC
)
1089 EMPTY_FUNCTION_ENTRY
1092 PHP_MINIT_FUNCTION(http_client
)
1094 zend_class_entry ce
= {0};
1096 INIT_NS_CLASS_ENTRY(ce
, "http", "Client", php_http_client_methods
);
1097 php_http_client_class_entry
= zend_register_internal_class_ex(&ce
, NULL
, NULL TSRMLS_CC
);
1098 php_http_client_class_entry
->create_object
= php_http_client_object_new
;
1099 zend_class_implements(php_http_client_class_entry TSRMLS_CC
, 1, spl_ce_SplSubject
);
1100 memcpy(&php_http_client_object_handlers
, zend_get_std_object_handlers(), sizeof(zend_object_handlers
));
1101 php_http_client_object_handlers
.clone_obj
= NULL
;
1102 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("observers"), ZEND_ACC_PRIVATE TSRMLS_CC
);
1103 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("options"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1104 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("history"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1105 zend_declare_property_bool(php_http_client_class_entry
, ZEND_STRL("recordHistory"), 0, ZEND_ACC_PUBLIC TSRMLS_CC
);
1107 zend_hash_init(&php_http_client_drivers
, 2, NULL
, NULL
, 1);
1112 PHP_MSHUTDOWN_FUNCTION(http_client
)
1114 zend_hash_destroy(&php_http_client_drivers
);