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-2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
14 #include "php_http_client.h"
16 #include <ext/spl/spl_observer.h>
19 * array of name => php_http_client_driver_t*
21 static HashTable php_http_client_drivers
;
23 PHP_HTTP_API STATUS
php_http_client_driver_add(php_http_client_driver_t
*driver
)
25 return zend_hash_add(&php_http_client_drivers
, driver
->name_str
, driver
->name_len
+ 1, (void *) driver
, sizeof(php_http_client_driver_t
), NULL
);
28 PHP_HTTP_API STATUS
php_http_client_driver_get(const char *name_str
, size_t name_len
, php_http_client_driver_t
*driver
)
30 php_http_client_driver_t
*tmp
;
32 if ((name_str
&& SUCCESS
== zend_hash_find(&php_http_client_drivers
, name_str
, name_len
+ 1, (void *) &tmp
))
33 || (SUCCESS
== zend_hash_get_current_data(&php_http_client_drivers
, (void *) &tmp
))) {
40 static int apply_driver_list(void *p
, void *arg TSRMLS_DC
)
42 php_http_client_driver_t
*d
= p
;
46 ZVAL_STRINGL(zname
, d
->name_str
, d
->name_len
, 1);
48 zend_hash_next_index_insert(arg
, &zname
, sizeof(zval
*), NULL
);
49 return ZEND_HASH_APPLY_KEEP
;
52 PHP_HTTP_API
void php_http_client_driver_list(HashTable
*ht TSRMLS_DC
)
54 zend_hash_apply_with_argument(&php_http_client_drivers
, apply_driver_list
, ht TSRMLS_CC
);
57 void php_http_client_options_set_subr(zval
*this_ptr
, char *key
, size_t len
, zval
*opts
, int overwrite TSRMLS_DC
)
59 if (overwrite
|| (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
)))) {
60 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
61 zval
*old_opts
, *new_opts
, **entry
= NULL
;
63 MAKE_STD_ZVAL(new_opts
);
65 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
66 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
67 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL_P(new_opts
));
71 if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
73 zend_symtable_update(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &opts
, sizeof(zval
*), NULL
);
75 zend_symtable_del(Z_ARRVAL_P(new_opts
), key
, len
);
77 } else if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
78 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &entry
)) {
79 array_join(Z_ARRVAL_P(opts
), Z_ARRVAL_PP(entry
), 0, 0);
82 zend_symtable_update(Z_ARRVAL_P(new_opts
), key
, len
, (void *) &opts
, sizeof(zval
*), NULL
);
86 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
87 zval_ptr_dtor(&new_opts
);
91 void php_http_client_options_set(zval
*this_ptr
, zval
*opts TSRMLS_DC
)
93 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
96 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
97 zend_bool is_client
= instanceof_function(this_ce
, php_http_client_class_entry TSRMLS_CC
);
99 MAKE_STD_ZVAL(new_opts
);
100 array_init(new_opts
);
102 if (!opts
|| !zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
103 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
104 zval_ptr_dtor(&new_opts
);
106 zval
*old_opts
, *add_opts
, **opt
;
108 MAKE_STD_ZVAL(add_opts
);
109 array_init(add_opts
);
110 /* some options need extra attention -- thus cannot use array_merge() directly */
111 FOREACH_KEYVAL(pos
, opts
, key
, opt
) {
112 if (key
.type
== HASH_KEY_IS_STRING
) {
113 #define KEYMATCH(k, s) ((sizeof(s)==k.len) && !strcasecmp(k.str, s))
114 if (Z_TYPE_PP(opt
) == IS_ARRAY
&& (KEYMATCH(key
, "ssl") || KEYMATCH(key
, "cookies"))) {
115 php_http_client_options_set_subr(getThis(), key
.str
, key
.len
, *opt
, 0 TSRMLS_CC
);
116 } else if (is_client
&& (KEYMATCH(key
, "recordHistory") || KEYMATCH(key
, "responseMessageClass"))) {
117 zend_update_property(this_ce
, getThis(), key
.str
, key
.len
-1, *opt TSRMLS_CC
);
118 } else if (Z_TYPE_PP(opt
) == IS_NULL
) {
119 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
120 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
121 zend_symtable_del(Z_ARRVAL_P(old_opts
), key
.str
, key
.len
);
125 add_assoc_zval_ex(add_opts
, key
.str
, key
.len
, *opt
);
130 old_opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
131 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
132 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL_P(new_opts
));
134 array_join(Z_ARRVAL_P(add_opts
), Z_ARRVAL_P(new_opts
), 0, 0);
135 zend_update_property(this_ce
, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC
);
136 zval_ptr_dtor(&new_opts
);
137 zval_ptr_dtor(&add_opts
);
141 void php_http_client_options_get_subr(zval
*this_ptr
, char *key
, size_t len
, zval
*return_value TSRMLS_DC
)
143 zend_class_entry
*this_ce
= Z_OBJCE_P(getThis());
144 zval
**options
, *opts
= zend_read_property(this_ce
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
146 if ((Z_TYPE_P(opts
) == IS_ARRAY
) && (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(opts
), key
, len
, (void *) &options
))) {
147 RETVAL_ZVAL(*options
, 1, 0);
151 static void queue_dtor(void *enqueued
)
153 php_http_client_enqueue_t
*e
= enqueued
;
160 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
)
162 php_http_client_t
*free_h
= NULL
;
165 free_h
= h
= emalloc(sizeof(*h
));
167 memset(h
, 0, sizeof(*h
));
172 } else if (ops
->rsrc
) {
173 h
->rf
= php_resource_factory_init(NULL
, h
->ops
->rsrc
, h
, NULL
);
175 zend_llist_init(&h
->requests
, sizeof(php_http_client_enqueue_t
), queue_dtor
, 0);
176 zend_llist_init(&h
->responses
, sizeof(void *), NULL
, 0);
177 TSRMLS_SET_CTX(h
->ts
);
180 if (!(h
= h
->ops
->init(h
, init_arg
))) {
181 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Could not initialize client");
191 PHP_HTTP_API php_http_client_t
*php_http_client_copy(php_http_client_t
*from
, php_http_client_t
*to
)
193 if (from
->ops
->copy
) {
194 return from
->ops
->copy(from
, to
);
200 PHP_HTTP_API
void php_http_client_dtor(php_http_client_t
*h
)
202 php_http_client_reset(h
);
208 php_resource_factory_free(&h
->rf
);
211 PHP_HTTP_API
void php_http_client_free(php_http_client_t
**h
) {
213 php_http_client_dtor(*h
);
219 PHP_HTTP_API STATUS
php_http_client_enqueue(php_http_client_t
*h
, php_http_client_enqueue_t
*enqueue
)
221 TSRMLS_FETCH_FROM_CTX(h
->ts
);
223 if (h
->ops
->enqueue
) {
224 if (php_http_client_enqueued(h
, enqueue
->request
, NULL
)) {
225 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to enqueue request; request already in queue");
228 return h
->ops
->enqueue(h
, enqueue
);
234 PHP_HTTP_API STATUS
php_http_client_dequeue(php_http_client_t
*h
, php_http_message_t
*request
)
236 TSRMLS_FETCH_FROM_CTX(h
->ts
);
238 if (h
->ops
->dequeue
) {
239 php_http_client_enqueue_t
*enqueue
= php_http_client_enqueued(h
, request
, NULL
);
242 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to dequeue request; request not in queue");
245 return h
->ops
->dequeue(h
, enqueue
);
250 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
)
252 zend_llist_element
*el
= NULL
;
255 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
256 if (compare_func((php_http_client_enqueue_t
*) el
->data
, compare_arg
)) {
261 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
262 if (((php_http_client_enqueue_t
*) el
->data
)->request
== compare_arg
) {
267 return el
? (php_http_client_enqueue_t
*) el
->data
: NULL
;
270 PHP_HTTP_API STATUS
php_http_client_wait(php_http_client_t
*h
, struct timeval
*custom_timeout
)
273 return h
->ops
->wait(h
, custom_timeout
);
279 PHP_HTTP_API
int php_http_client_once(php_http_client_t
*h
)
282 return h
->ops
->once(h
);
288 PHP_HTTP_API STATUS
php_http_client_exec(php_http_client_t
*h
)
291 return h
->ops
->exec(h
);
297 PHP_HTTP_API
void php_http_client_reset(php_http_client_t
*h
)
303 zend_llist_clean(&h
->requests
);
304 zend_llist_clean(&h
->responses
);
307 PHP_HTTP_API STATUS
php_http_client_setopt(php_http_client_t
*h
, php_http_client_setopt_opt_t opt
, void *arg
)
309 if (h
->ops
->setopt
) {
310 return h
->ops
->setopt(h
, opt
, arg
);
316 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
)
318 if (h
->ops
->getopt
) {
319 return h
->ops
->getopt(h
, opt
, arg
, res_ptr
);
324 zend_class_entry
*php_http_client_class_entry
;
325 static zend_object_handlers php_http_client_object_handlers
;
327 void php_http_client_object_free(void *object TSRMLS_DC
)
329 php_http_client_object_t
*o
= (php_http_client_object_t
*) object
;
331 php_http_client_free(&o
->client
);
332 zend_object_std_dtor((zend_object
*) o TSRMLS_CC
);
336 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
)
338 php_http_client_object_t
*o
;
340 o
= ecalloc(1, sizeof(php_http_client_object_t
));
341 zend_object_std_init((zend_object
*) o
, ce TSRMLS_CC
);
342 object_properties_init((zend_object
*) o
, ce
);
350 o
->zv
.handle
= zend_objects_store_put(o
, NULL
, php_http_client_object_free
, NULL TSRMLS_CC
);
351 o
->zv
.handlers
= &php_http_client_object_handlers
;
356 zend_object_value
php_http_client_object_new(zend_class_entry
*ce TSRMLS_DC
)
358 return php_http_client_object_new_ex(ce
, NULL
, NULL TSRMLS_CC
);
361 static void handle_history(zval
*zclient
, php_http_message_t
*request
, php_http_message_t
*response TSRMLS_DC
)
363 zval
*new_hist
, *old_hist
= zend_read_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), 0 TSRMLS_CC
);
364 php_http_message_t
*zipped
= php_http_message_zip(response
, request
);
365 zend_object_value ov
= php_http_message_object_new_ex(php_http_message_class_entry
, zipped
, NULL TSRMLS_CC
);
367 MAKE_STD_ZVAL(new_hist
);
368 ZVAL_OBJVAL(new_hist
, ov
, 0);
370 if (Z_TYPE_P(old_hist
) == IS_OBJECT
) {
371 php_http_message_object_prepend(new_hist
, old_hist
, 1 TSRMLS_CC
);
374 zend_update_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), new_hist TSRMLS_CC
);
375 zval_ptr_dtor(&new_hist
);
378 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
)
381 php_http_message_t
*msg
;
382 php_http_client_progress_state_t
*progress
;
383 TSRMLS_FETCH_FROM_CTX(client
->ts
);
385 INIT_PZVAL(&zclient
);
386 ZVAL_OBJVAL(&zclient
, ((php_http_client_object_t
*) arg
)->zv
, 0);
388 if ((msg
= *response
)) {
389 php_http_message_object_t
*msg_obj
;
390 zval
*info
, *zresponse
, *zrequest
;
393 if (i_zend_is_true(zend_read_property(php_http_client_class_entry
, &zclient
, ZEND_STRL("recordHistory"), 0 TSRMLS_CC
))) {
394 handle_history(&zclient
, *request
, *response TSRMLS_CC
);
397 /* hard detach, redirects etc. are in the history */
398 php_http_message_free(&msg
->parent
);
401 MAKE_STD_ZVAL(zresponse
);
402 ZVAL_OBJVAL(zresponse
, php_http_message_object_new_ex(php_http_client_response_class_entry
, msg
, &msg_obj TSRMLS_CC
), 0);
404 MAKE_STD_ZVAL(zrequest
);
405 ZVAL_OBJVAL(zrequest
, ((php_http_message_object_t
*) e
->opaque
)->zv
, 1);
407 php_http_message_object_prepend(zresponse
, zrequest
, 1 TSRMLS_CC
);
411 info_ht
= HASH_OF(info
);
412 php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, e
->request
, &info_ht
);
413 zend_update_property(php_http_client_response_class_entry
, zresponse
, ZEND_STRL("transferInfo"), info TSRMLS_CC
);
414 zval_ptr_dtor(&info
);
416 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
417 zend_llist_add_element(&client
->responses
, &msg_obj
);
419 if (e
->closure
.fci
.size
) {
422 zend_fcall_info_argn(&e
->closure
.fci TSRMLS_CC
, 1, &zresponse
);
423 with_error_handling(EH_NORMAL
, NULL
) {
424 zend_fcall_info_call(&e
->closure
.fci
, &e
->closure
.fcc
, &retval
, NULL TSRMLS_CC
);
425 } end_error_handling();
426 zend_fcall_info_argn(&e
->closure
.fci TSRMLS_CC
, 0);
429 if (Z_TYPE_P(retval
) == IS_BOOL
&& Z_BVAL_P(retval
)) {
430 php_http_client_dequeue(client
, e
->request
);
432 zval_ptr_dtor(&retval
);
436 zval_ptr_dtor(&zresponse
);
437 zval_ptr_dtor(&zrequest
);
440 if (SUCCESS
== php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, e
->request
, &progress
)) {
441 progress
->info
= "finished";
442 progress
->finished
= 1;
443 client
->callback
.progress
.func(client
->callback
.progress
.arg
, client
, e
, progress
);
449 static void handle_progress(void *arg
, php_http_client_t
*client
, php_http_client_enqueue_t
*e
, php_http_client_progress_state_t
*progress
)
451 zval
*zrequest
, *zprogress
, *retval
= NULL
, *zclient
;
452 TSRMLS_FETCH_FROM_CTX(client
->ts
);
454 MAKE_STD_ZVAL(zclient
);
455 ZVAL_OBJVAL(zclient
, ((php_http_client_object_t
*) arg
)->zv
, 1);
456 MAKE_STD_ZVAL(zrequest
);
457 ZVAL_OBJVAL(zrequest
, ((php_http_message_object_t
*) e
->opaque
)->zv
, 1);
458 MAKE_STD_ZVAL(zprogress
);
459 object_init(zprogress
);
460 add_property_bool(zprogress
, "started", progress
->started
);
461 add_property_bool(zprogress
, "finished", progress
->finished
);
462 add_property_string(zprogress
, "info", STR_PTR(progress
->info
), 1);
463 add_property_double(zprogress
, "dltotal", progress
->dl
.total
);
464 add_property_double(zprogress
, "dlnow", progress
->dl
.now
);
465 add_property_double(zprogress
, "ultotal", progress
->ul
.total
);
466 add_property_double(zprogress
, "ulnow", progress
->ul
.now
);
467 with_error_handling(EH_NORMAL
, NULL
) {
468 zend_call_method_with_2_params(&zclient
, NULL
, NULL
, "notify", &retval
, zrequest
, zprogress
);
469 } end_error_handling();
470 zval_ptr_dtor(&zclient
);
471 zval_ptr_dtor(&zrequest
);
472 zval_ptr_dtor(&zprogress
);
474 zval_ptr_dtor(&retval
);
478 static void response_dtor(void *data
)
480 php_http_message_object_t
*msg_obj
= *(php_http_message_object_t
**) data
;
481 TSRMLS_FETCH_FROM_CTX(msg_obj
->message
->ts
);
483 zend_objects_store_del_ref_by_handle_ex(msg_obj
->zv
.handle
, msg_obj
->zv
.handlers TSRMLS_CC
);
486 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_construct
, 0, 0, 0)
487 ZEND_ARG_INFO(0, driver
)
488 ZEND_ARG_INFO(0, persistent_handle_id
)
490 static PHP_METHOD(HttpClient
, __construct
)
492 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
493 char *driver_str
= NULL
, *persistent_handle_str
= NULL
;
494 int driver_len
= 0, persistent_handle_len
= 0;
496 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|ss", &driver_str
, &driver_len
, &persistent_handle_str
, &persistent_handle_len
)) {
497 php_http_client_driver_t driver
;
499 if (SUCCESS
== php_http_client_driver_get(driver_str
, driver_len
, &driver
)) {
500 php_resource_factory_t
*rf
= NULL
;
501 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
505 object_init_ex(os
, spl_ce_SplObjectStorage
);
506 zend_update_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), os TSRMLS_CC
);
509 if (persistent_handle_len
) {
512 php_persistent_handle_factory_t
*pf
;
514 name_len
= spprintf(&name_str
, 0, "http\\Client\\%s", driver
.name_str
);
515 php_http_pretty_key(name_str
+ sizeof("http\\Client"), driver
.name_len
, 1, 1);
517 if ((pf
= php_persistent_handle_concede(NULL
, name_str
, name_len
, persistent_handle_str
, persistent_handle_len
, NULL
, NULL TSRMLS_CC
))) {
518 rf
= php_resource_factory_init(NULL
, php_persistent_handle_get_resource_factory_ops(), pf
, (void (*)(void *)) php_persistent_handle_abandon
);
524 if ((obj
->client
= php_http_client_init(NULL
, driver
.client_ops
, rf
, NULL TSRMLS_CC
))) {
525 obj
->client
->callback
.response
.func
= handle_response
;
526 obj
->client
->callback
.response
.arg
= obj
;
527 obj
->client
->callback
.progress
.func
= handle_progress
;
528 obj
->client
->callback
.progress
.arg
= obj
;
530 obj
->client
->responses
.dtor
= response_dtor
;
533 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to locate \"%s\" client request handler", driver_str
);
536 } end_error_handling();
539 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_reset
, 0, 0, 0)
541 static PHP_METHOD(HttpClient
, reset
)
543 if (SUCCESS
== zend_parse_parameters_none()) {
544 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
547 php_http_client_reset(obj
->client
);
549 RETVAL_ZVAL(getThis(), 1, 0);
552 static HashTable
*combined_options(zval
*client
, zval
*request TSRMLS_DC
)
556 zval
*z_roptions
= NULL
, *z_coptions
= zend_read_property(php_http_client_class_entry
, client
, ZEND_STRL("options"), 0 TSRMLS_CC
);
558 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
559 num_options
= zend_hash_num_elements(Z_ARRVAL_P(z_coptions
));
561 zend_call_method_with_0_params(&request
, NULL
, NULL
, "getOptions", &z_roptions
);
562 if (z_roptions
&& Z_TYPE_P(z_roptions
) == IS_ARRAY
) {
563 int num
= zend_hash_num_elements(Z_ARRVAL_P(z_roptions
));
564 if (num
> num_options
) {
568 ALLOC_HASHTABLE(options
);
569 ZEND_INIT_SYMTABLE_EX(options
, num_options
, 0);
570 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
571 array_copy(Z_ARRVAL_P(z_coptions
), options
);
574 if (Z_TYPE_P(z_roptions
) == IS_ARRAY
) {
575 array_join(Z_ARRVAL_P(z_roptions
), options
, 0, 0);
577 zval_ptr_dtor(&z_roptions
);
582 static void msg_queue_dtor(php_http_client_enqueue_t
*e
)
584 php_http_message_object_t
*msg_obj
= e
->opaque
;
585 TSRMLS_FETCH_FROM_CTX(msg_obj
->message
->ts
);
587 zend_objects_store_del_ref_by_handle_ex(msg_obj
->zv
.handle
, msg_obj
->zv
.handlers TSRMLS_CC
);
588 zend_hash_destroy(e
->options
);
589 FREE_HASHTABLE(e
->options
);
591 if (e
->closure
.fci
.size
) {
592 zval_ptr_dtor(&e
->closure
.fci
.function_name
);
593 if (e
->closure
.fci
.object_ptr
) {
594 zval_ptr_dtor(&e
->closure
.fci
.object_ptr
);
599 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enqueue
, 0, 0, 1)
600 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
601 ZEND_ARG_INFO(0, callable
)
603 static PHP_METHOD(HttpClient
, enqueue
)
605 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
607 zend_fcall_info fci
= empty_fcall_info
;
608 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
610 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O|f", &request
, php_http_client_request_class_entry
, &fci
, &fcc
)) {
611 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
612 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
614 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
615 php_http_error(HE_WARNING
, PHP_HTTP_E_CLIENT
, "Failed to enqueue request; request already in queue");
617 php_http_client_enqueue_t q
;
618 q
.request
= msg_obj
->message
;
619 q
.options
= combined_options(getThis(), request TSRMLS_CC
);
620 q
.dtor
= msg_queue_dtor
;
626 Z_ADDREF_P(fci
.function_name
);
627 if (fci
.object_ptr
) {
628 Z_ADDREF_P(fci
.object_ptr
);
632 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
633 php_http_client_enqueue(obj
->client
, &q
);
636 } end_error_handling();
638 RETVAL_ZVAL(getThis(), 1, 0);
641 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_dequeue
, 0, 0, 1)
642 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
644 static PHP_METHOD(HttpClient
, dequeue
)
646 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
649 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_class_entry
)) {
650 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
651 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
653 php_http_client_dequeue(obj
->client
, msg_obj
->message
);
655 } end_error_handling();
657 RETVAL_ZVAL(getThis(), 1, 0);
660 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_requeue
, 0, 0, 1)
661 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
662 ZEND_ARG_INFO(0, callable
)
664 static PHP_METHOD(HttpClient
, requeue
)
666 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
668 zend_fcall_info fci
= empty_fcall_info
;
669 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
671 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O|f", &request
, php_http_client_request_class_entry
, &fci
, &fcc
)) {
672 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
673 php_http_message_object_t
*msg_obj
= zend_object_store_get_object(request TSRMLS_CC
);
674 php_http_client_enqueue_t q
;
675 q
.request
= msg_obj
->message
;
676 q
.options
= combined_options(getThis(), request TSRMLS_CC
);
677 q
.dtor
= msg_queue_dtor
;
683 Z_ADDREF_P(fci
.function_name
);
684 if (fci
.object_ptr
) {
685 Z_ADDREF_P(fci
.object_ptr
);
689 zend_objects_store_add_ref_by_handle(msg_obj
->zv
.handle TSRMLS_CC
);
690 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
691 php_http_client_dequeue(obj
->client
, msg_obj
->message
);
693 php_http_client_enqueue(obj
->client
, &q
);
695 } end_error_handling();
697 RETVAL_ZVAL(getThis(), 1, 0);
700 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_count
, 0, 0, 0)
702 static PHP_METHOD(HttpClient
, count
)
704 if (SUCCESS
== zend_parse_parameters_none()) {
705 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
707 RETVAL_LONG(zend_llist_count(&obj
->client
->requests
));
711 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getResponse
, 0, 0, 0)
712 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
714 static PHP_METHOD(HttpClient
, getResponse
)
716 zval
*zrequest
= NULL
;
718 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|O", &zrequest
, php_http_client_request_class_entry
)) {
719 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
722 /* pop off the last respone */
723 if (obj
->client
->responses
.tail
) {
724 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) obj
->client
->responses
.tail
->data
;
728 RETVAL_OBJVAL(response_obj
->zv
, 1);
729 zend_llist_remove_tail(&obj
->client
->responses
);
733 /* lookup the response with the request */
734 zend_llist_element
*el
= NULL
;
735 php_http_message_object_t
*req_obj
= zend_object_store_get_object(zrequest TSRMLS_CC
);
737 for (el
= obj
->client
->responses
.head
; el
; el
= el
->next
) {
738 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) el
->data
;
740 if (response_obj
->message
->parent
== req_obj
->message
) {
741 RETVAL_OBJVAL(response_obj
->zv
, 1);
749 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getHistory
, 0, 0, 0)
751 static PHP_METHOD(HttpClient
, getHistory
)
753 if (SUCCESS
== zend_parse_parameters_none()) {
754 zval
*zhistory
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("history"), 0 TSRMLS_CC
);
755 RETVAL_ZVAL(zhistory
, 1, 0);
759 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_send
, 0, 0, 0)
761 static PHP_METHOD(HttpClient
, send
)
763 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
764 if (SUCCESS
== zend_parse_parameters_none()) {
765 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
766 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
768 php_http_client_exec(obj
->client
);
769 } end_error_handling();
771 } end_error_handling();
773 RETVAL_ZVAL(getThis(), 1, 0);
776 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_once
, 0, 0, 0)
778 static PHP_METHOD(HttpClient
, once
)
780 if (SUCCESS
== zend_parse_parameters_none()) {
781 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
783 RETURN_BOOL(0 < php_http_client_once(obj
->client
));
787 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_wait
, 0, 0, 0)
788 ZEND_ARG_INFO(0, timeout
)
790 static PHP_METHOD(HttpClient
, wait
)
794 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|d", &timeout
)) {
795 struct timeval timeout_val
;
796 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
798 timeout_val
.tv_sec
= (time_t) timeout
;
799 timeout_val
.tv_usec
= PHP_HTTP_USEC(timeout
) % PHP_HTTP_MCROSEC
;
801 RETURN_BOOL(SUCCESS
== php_http_client_wait(obj
->client
, timeout
> 0 ? &timeout_val
: NULL
));
805 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enablePipelining
, 0, 0, 0)
806 ZEND_ARG_INFO(0, enable
)
808 static PHP_METHOD(HttpClient
, enablePipelining
)
810 zend_bool enable
= 1;
812 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &enable
)) {
813 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
815 php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING
, &enable
);
817 RETVAL_ZVAL(getThis(), 1, 0);
820 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enableEvents
, 0, 0, 0)
821 ZEND_ARG_INFO(0, enable
)
823 static PHP_METHOD(HttpClient
, enableEvents
)
825 zend_bool enable
= 1;
827 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &enable
)) {
828 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
830 php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_USE_EVENTS
, &enable
);
832 RETVAL_ZVAL(getThis(), 1, 0);
835 static int notify(zend_object_iterator
*iter
, void *puser TSRMLS_DC
)
837 zval
**observer
= NULL
, ***args
= puser
;
839 iter
->funcs
->get_current_data(iter
, &observer TSRMLS_CC
);
841 return php_http_method_call(*observer
, ZEND_STRL("update"), args
[2]?3:args
[1]?2:args
[0]?1:0, args
, NULL TSRMLS_CC
);
846 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify
, 0, 0, 0)
847 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
849 static PHP_METHOD(HttpClient
, notify
)
851 zval
*request
= NULL
, *zprogress
= NULL
;
853 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|O!o!", &request
, php_http_client_request_class_entry
, &zprogress
)) {
854 zval
**args
[3], *observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
856 if (Z_TYPE_P(observers
) == IS_OBJECT
) {
857 Z_ADDREF_P(getThis());
858 args
[0] = &getThis();
864 Z_ADDREF_P(zprogress
);
866 args
[2] = &zprogress
;
867 spl_iterator_apply(observers
, notify
, args TSRMLS_CC
);
868 zval_ptr_dtor(&getThis());
870 zval_ptr_dtor(&request
);
873 zval_ptr_dtor(&zprogress
);
878 RETVAL_ZVAL(getThis(), 1, 0);
881 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach
, 0, 0, 1)
882 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
884 static PHP_METHOD(HttpClient
, attach
)
888 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &observer
, spl_ce_SplObserver
)) {
889 zval
*retval
= NULL
, *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
, "attach", &retval
, observer
);
892 zval_ptr_dtor(&retval
);
896 RETVAL_ZVAL(getThis(), 1, 0);
899 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach
, 0, 0, 1)
900 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
902 static PHP_METHOD(HttpClient
, detach
)
906 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &observer
, spl_ce_SplObserver
)) {
907 zval
*retval
, *observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
908 zend_call_method_with_1_params(&observers
, NULL
, NULL
, "detach", &retval
, observer
);
909 zval_ptr_dtor(&retval
);
912 RETVAL_ZVAL(getThis(), 1, 0);
915 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getObservers
, 0, 0, 0)
917 static PHP_METHOD(HttpClient
, getObservers
)
919 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
920 if (SUCCESS
== zend_parse_parameters_none()) {
921 zval
*observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC
);
922 RETVAL_ZVAL(observers
, 1, 0);
924 } end_error_handling();
927 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getProgressInfo
, 0, 0, 1)
928 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
930 static PHP_METHOD(HttpClient
, getProgressInfo
)
934 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
935 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_class_entry
)) {
936 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
937 php_http_message_object_t
*req_obj
= zend_object_store_get_object(request TSRMLS_CC
);
938 php_http_client_progress_state_t
*progress
;
940 if (SUCCESS
== php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, req_obj
->message
, &progress
)) {
941 object_init(return_value
);
942 add_property_bool(return_value
, "started", progress
->started
);
943 add_property_bool(return_value
, "finished", progress
->finished
);
944 add_property_string(return_value
, "info", STR_PTR(progress
->info
), 1);
945 add_property_double(return_value
, "dltotal", progress
->dl
.total
);
946 add_property_double(return_value
, "dlnow", progress
->dl
.now
);
947 add_property_double(return_value
, "ultotal", progress
->ul
.total
);
948 add_property_double(return_value
, "ulnow", progress
->ul
.now
);
951 } end_error_handling();
954 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getTransferInfo
, 0, 0, 1)
955 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
957 static PHP_METHOD(HttpClient
, getTransferInfo
)
961 with_error_handling(EH_THROW
, php_http_exception_class_entry
) {
962 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O", &request
, php_http_client_request_class_entry
)) {
964 php_http_client_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
965 php_http_message_object_t
*req_obj
= zend_object_store_get_object(request TSRMLS_CC
);
967 object_init(return_value
);
968 info
= HASH_OF(return_value
);
969 php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, req_obj
->message
, &info
);
971 } end_error_handling();
974 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setOptions
, 0, 0, 0)
975 ZEND_ARG_ARRAY_INFO(0, options
, 1)
977 static PHP_METHOD(HttpClient
, setOptions
)
981 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
982 php_http_client_options_set(getThis(), opts TSRMLS_CC
);
984 RETVAL_ZVAL(getThis(), 1, 0);
988 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getOptions
, 0, 0, 0)
990 static PHP_METHOD(HttpClient
, getOptions
)
992 if (SUCCESS
== zend_parse_parameters_none()) {
993 zval
*options
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC
);
994 RETVAL_ZVAL(options
, 1, 0);
998 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setSslOptions
, 0, 0, 0)
999 ZEND_ARG_ARRAY_INFO(0, ssl_option
, 1)
1000 ZEND_END_ARG_INFO();
1001 static PHP_METHOD(HttpClient
, setSslOptions
)
1005 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1006 php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts
, 1 TSRMLS_CC
);
1008 RETVAL_ZVAL(getThis(), 1, 0);
1012 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addSslOptions
, 0, 0, 0)
1013 ZEND_ARG_ARRAY_INFO(0, ssl_options
, 1)
1014 ZEND_END_ARG_INFO();
1015 static PHP_METHOD(HttpClient
, addSslOptions
)
1019 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1020 php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts
, 0 TSRMLS_CC
);
1022 RETVAL_ZVAL(getThis(), 1, 0);
1026 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getSslOptions
, 0, 0, 0)
1027 ZEND_END_ARG_INFO();
1028 static PHP_METHOD(HttpClient
, getSslOptions
)
1030 if (SUCCESS
== zend_parse_parameters_none()) {
1031 php_http_client_options_get_subr(getThis(), ZEND_STRS("ssl"), return_value TSRMLS_CC
);
1035 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setCookies
, 0, 0, 0)
1036 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1037 ZEND_END_ARG_INFO();
1038 static PHP_METHOD(HttpClient
, setCookies
)
1042 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1043 php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts
, 1 TSRMLS_CC
);
1045 RETVAL_ZVAL(getThis(), 1, 0);
1049 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addCookies
, 0, 0, 0)
1050 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1051 ZEND_END_ARG_INFO();
1052 static PHP_METHOD(HttpClient
, addCookies
)
1056 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|a!/", &opts
)) {
1057 php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts
, 0 TSRMLS_CC
);
1059 RETVAL_ZVAL(getThis(), 1, 0);
1063 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getCookies
, 0, 0, 0)
1064 ZEND_END_ARG_INFO();
1065 static PHP_METHOD(HttpClient
, getCookies
)
1067 if (SUCCESS
== zend_parse_parameters_none()) {
1068 php_http_client_options_get_subr(getThis(), ZEND_STRS("cookies"), return_value TSRMLS_CC
);
1072 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableDrivers
, 0, 0, 0)
1073 ZEND_END_ARG_INFO();
1074 static PHP_METHOD(HttpClient
, getAvailableDrivers
) {
1075 if (SUCCESS
== zend_parse_parameters_none()) {
1076 array_init(return_value
);
1077 php_http_client_driver_list(Z_ARRVAL_P(return_value
) TSRMLS_CC
);
1081 static zend_function_entry php_http_client_methods
[] = {
1082 PHP_ME(HttpClient
, __construct
, ai_HttpClient_construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
1083 PHP_ME(HttpClient
, reset
, ai_HttpClient_reset
, ZEND_ACC_PUBLIC
)
1084 PHP_ME(HttpClient
, enqueue
, ai_HttpClient_enqueue
, ZEND_ACC_PUBLIC
)
1085 PHP_ME(HttpClient
, dequeue
, ai_HttpClient_dequeue
, ZEND_ACC_PUBLIC
)
1086 PHP_ME(HttpClient
, requeue
, ai_HttpClient_requeue
, ZEND_ACC_PUBLIC
)
1087 PHP_ME(HttpClient
, count
, ai_HttpClient_count
, ZEND_ACC_PUBLIC
)
1088 PHP_ME(HttpClient
, send
, ai_HttpClient_send
, ZEND_ACC_PUBLIC
)
1089 PHP_ME(HttpClient
, once
, ai_HttpClient_once
, ZEND_ACC_PUBLIC
)
1090 PHP_ME(HttpClient
, wait
, ai_HttpClient_wait
, ZEND_ACC_PUBLIC
)
1091 PHP_ME(HttpClient
, getResponse
, ai_HttpClient_getResponse
, ZEND_ACC_PUBLIC
)
1092 PHP_ME(HttpClient
, getHistory
, ai_HttpClient_getHistory
, ZEND_ACC_PUBLIC
)
1093 PHP_ME(HttpClient
, enablePipelining
, ai_HttpClient_enablePipelining
, ZEND_ACC_PUBLIC
)
1094 PHP_ME(HttpClient
, enableEvents
, ai_HttpClient_enableEvents
, ZEND_ACC_PUBLIC
)
1095 PHP_ME(HttpClient
, notify
, ai_HttpClient_notify
, ZEND_ACC_PUBLIC
)
1096 PHP_ME(HttpClient
, attach
, ai_HttpClient_attach
, ZEND_ACC_PUBLIC
)
1097 PHP_ME(HttpClient
, detach
, ai_HttpClient_detach
, ZEND_ACC_PUBLIC
)
1098 PHP_ME(HttpClient
, getObservers
, ai_HttpClient_getObservers
, ZEND_ACC_PUBLIC
)
1099 PHP_ME(HttpClient
, getProgressInfo
, ai_HttpClient_getProgressInfo
, ZEND_ACC_PUBLIC
)
1100 PHP_ME(HttpClient
, getTransferInfo
, ai_HttpClient_getTransferInfo
, ZEND_ACC_PUBLIC
)
1101 PHP_ME(HttpClient
, setOptions
, ai_HttpClient_setOptions
, ZEND_ACC_PUBLIC
)
1102 PHP_ME(HttpClient
, getOptions
, ai_HttpClient_getOptions
, ZEND_ACC_PUBLIC
)
1103 PHP_ME(HttpClient
, setSslOptions
, ai_HttpClient_setSslOptions
, ZEND_ACC_PUBLIC
)
1104 PHP_ME(HttpClient
, addSslOptions
, ai_HttpClient_addSslOptions
, ZEND_ACC_PUBLIC
)
1105 PHP_ME(HttpClient
, getSslOptions
, ai_HttpClient_getSslOptions
, ZEND_ACC_PUBLIC
)
1106 PHP_ME(HttpClient
, setCookies
, ai_HttpClient_setCookies
, ZEND_ACC_PUBLIC
)
1107 PHP_ME(HttpClient
, addCookies
, ai_HttpClient_addCookies
, ZEND_ACC_PUBLIC
)
1108 PHP_ME(HttpClient
, getCookies
, ai_HttpClient_getCookies
, ZEND_ACC_PUBLIC
)
1109 PHP_ME(HttpClient
, getAvailableDrivers
, ai_HttpClient_getAvailableDrivers
, ZEND_ACC_PUBLIC
|ZEND_ACC_STATIC
)
1110 EMPTY_FUNCTION_ENTRY
1113 PHP_MINIT_FUNCTION(http_client
)
1115 zend_class_entry ce
= {0};
1117 INIT_NS_CLASS_ENTRY(ce
, "http", "Client", php_http_client_methods
);
1118 php_http_client_class_entry
= zend_register_internal_class_ex(&ce
, NULL
, NULL TSRMLS_CC
);
1119 php_http_client_class_entry
->create_object
= php_http_client_object_new
;
1120 zend_class_implements(php_http_client_class_entry TSRMLS_CC
, 2, spl_ce_SplSubject
, spl_ce_Countable
);
1121 memcpy(&php_http_client_object_handlers
, zend_get_std_object_handlers(), sizeof(zend_object_handlers
));
1122 php_http_client_object_handlers
.clone_obj
= NULL
;
1123 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("observers"), ZEND_ACC_PRIVATE TSRMLS_CC
);
1124 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("options"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1125 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("history"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1126 zend_declare_property_bool(php_http_client_class_entry
, ZEND_STRL("recordHistory"), 0, ZEND_ACC_PUBLIC TSRMLS_CC
);
1128 zend_hash_init(&php_http_client_drivers
, 2, NULL
, NULL
, 1);
1133 PHP_MSHUTDOWN_FUNCTION(http_client
)
1135 zend_hash_destroy(&php_http_client_drivers
);
1144 * vim600: noet sw=4 ts=4 fdm=marker
1145 * vim<600: noet sw=4 ts=4