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-2014, 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 static void php_http_client_driver_hash_dtor(zval
*pData
)
25 pefree(Z_PTR_P(pData
), 1);
28 ZEND_RESULT_CODE
php_http_client_driver_add(php_http_client_driver_t
*driver
)
30 return zend_hash_add_mem(&php_http_client_drivers
, driver
->driver_name
, (void *) driver
, sizeof(php_http_client_driver_t
))
34 php_http_client_driver_t
*php_http_client_driver_get(zend_string
*name
)
37 php_http_client_driver_t
*tmp
;
39 if (name
&& (tmp
= zend_hash_find_ptr(&php_http_client_drivers
, name
))) {
42 if ((ztmp
= zend_hash_get_current_data(&php_http_client_drivers
))) {
48 static int apply_driver_list(zval
*p
, void *arg
)
50 php_http_client_driver_t
*d
= Z_PTR_P(p
);
53 ZVAL_STR_COPY(&zname
, d
->driver_name
);
55 zend_hash_next_index_insert(arg
, &zname
);
56 return ZEND_HASH_APPLY_KEEP
;
59 void php_http_client_driver_list(HashTable
*ht
)
61 zend_hash_apply_with_argument(&php_http_client_drivers
, apply_driver_list
, ht
);
64 static zend_class_entry
*php_http_client_class_entry
;
65 zend_class_entry
*php_http_client_get_class_entry(void)
67 return php_http_client_class_entry
;
70 void php_http_client_options_set_subr(zval
*instance
, char *key
, size_t len
, zval
*opts
, int overwrite
)
72 if (overwrite
|| (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
)))) {
73 zend_class_entry
*this_ce
= Z_OBJCE_P(instance
);
74 zval old_opts_tmp
, *old_opts
, new_opts
, *entry
= NULL
;
76 array_init(&new_opts
);
77 old_opts
= zend_read_property(this_ce
, instance
, ZEND_STRL("options"), 0, &old_opts_tmp
);
78 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
79 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL(new_opts
));
83 if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
85 zend_symtable_str_update(Z_ARRVAL(new_opts
), key
, len
, opts
);
87 zend_symtable_str_del(Z_ARRVAL(new_opts
), key
, len
);
89 } else if (opts
&& zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
90 if ((entry
= zend_symtable_str_find(Z_ARRVAL(new_opts
), key
, len
))) {
91 array_join(Z_ARRVAL_P(opts
), Z_ARRVAL_P(entry
), 0, 0);
94 zend_symtable_str_update(Z_ARRVAL(new_opts
), key
, len
, opts
);
98 zend_update_property(this_ce
, instance
, ZEND_STRL("options"), &new_opts
);
99 zval_ptr_dtor(&new_opts
);
103 void php_http_client_options_set(zval
*instance
, zval
*opts
)
105 php_http_arrkey_t key
;
107 zend_class_entry
*this_ce
= Z_OBJCE_P(instance
);
108 zend_bool is_client
= instanceof_function(this_ce
, php_http_client_class_entry
);
110 array_init(&new_opts
);
112 if (!opts
|| !zend_hash_num_elements(Z_ARRVAL_P(opts
))) {
113 zend_update_property(this_ce
, instance
, ZEND_STRL("options"), &new_opts
);
114 zval_ptr_dtor(&new_opts
);
116 zval old_opts_tmp
, *old_opts
, add_opts
, *opt
;
118 array_init(&add_opts
);
119 /* some options need extra attention -- thus cannot use array_merge() directly */
120 ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(opts
), key
.h
, key
.key
, opt
)
123 if (Z_TYPE_P(opt
) == IS_ARRAY
&& (zend_string_equals_literal(key
.key
, "ssl") || zend_string_equals_literal(key
.key
, "cookies"))) {
124 php_http_client_options_set_subr(instance
, key
.key
->val
, key
.key
->len
, opt
, 0);
125 } else if (is_client
&& (zend_string_equals_literal(key
.key
, "recordHistory") || zend_string_equals_literal(key
.key
, "responseMessageClass"))) {
126 zend_update_property(this_ce
, instance
, key
.key
->val
, key
.key
->len
, opt
);
127 } else if (Z_TYPE_P(opt
) == IS_NULL
) {
128 old_opts
= zend_read_property(this_ce
, instance
, ZEND_STRL("options"), 0, &old_opts_tmp
);
129 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
130 zend_symtable_del(Z_ARRVAL_P(old_opts
), key
.key
);
134 add_assoc_zval_ex(&add_opts
, key
.key
->val
, key
.key
->len
, opt
);
138 ZEND_HASH_FOREACH_END();
140 old_opts
= zend_read_property(this_ce
, instance
, ZEND_STRL("options"), 0, &old_opts_tmp
);
141 if (Z_TYPE_P(old_opts
) == IS_ARRAY
) {
142 array_copy(Z_ARRVAL_P(old_opts
), Z_ARRVAL(new_opts
));
144 array_join(Z_ARRVAL(add_opts
), Z_ARRVAL(new_opts
), 0, 0);
145 zend_update_property(this_ce
, instance
, ZEND_STRL("options"), &new_opts
);
146 zval_ptr_dtor(&new_opts
);
147 zval_ptr_dtor(&add_opts
);
151 void php_http_client_options_get_subr(zval
*instance
, char *key
, size_t len
, zval
*return_value
)
153 zend_class_entry
*this_ce
= Z_OBJCE_P(instance
);
154 zval
*options
, opts_tmp
, *opts
= zend_read_property(this_ce
, instance
, ZEND_STRL("options"), 0, &opts_tmp
);
156 if ((Z_TYPE_P(opts
) == IS_ARRAY
) && (options
= zend_symtable_str_find(Z_ARRVAL_P(opts
), key
, len
))) {
157 RETVAL_ZVAL(options
, 1, 0);
161 static void queue_dtor(void *enqueued
)
163 php_http_client_enqueue_t
*e
= enqueued
;
170 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
)
172 php_http_client_t
*free_h
= NULL
;
175 free_h
= h
= emalloc(sizeof(*h
));
177 memset(h
, 0, sizeof(*h
));
182 } else if (ops
->rsrc
) {
183 h
->rf
= php_resource_factory_init(NULL
, h
->ops
->rsrc
, h
, NULL
);
185 zend_llist_init(&h
->requests
, sizeof(php_http_client_enqueue_t
), queue_dtor
, 0);
186 zend_llist_init(&h
->responses
, sizeof(void *), NULL
, 0);
189 if (!(h
= h
->ops
->init(h
, init_arg
))) {
190 php_error_docref(NULL
, E_WARNING
, "Could not initialize client");
198 php_http_client_t
*php_http_client_copy(php_http_client_t
*from
, php_http_client_t
*to
)
200 if (from
->ops
->copy
) {
201 return from
->ops
->copy(from
, to
);
207 void php_http_client_dtor(php_http_client_t
*h
)
209 php_http_client_reset(h
);
215 php_resource_factory_free(&h
->rf
);
218 void php_http_client_free(php_http_client_t
**h
) {
220 php_http_client_dtor(*h
);
226 ZEND_RESULT_CODE
php_http_client_enqueue(php_http_client_t
*h
, php_http_client_enqueue_t
*enqueue
)
228 if (h
->ops
->enqueue
) {
229 if (php_http_client_enqueued(h
, enqueue
->request
, NULL
)) {
230 php_error_docref(NULL
, E_WARNING
, "Failed to enqueue request; request already in queue");
233 return h
->ops
->enqueue(h
, enqueue
);
239 ZEND_RESULT_CODE
php_http_client_dequeue(php_http_client_t
*h
, php_http_message_t
*request
)
241 if (h
->ops
->dequeue
) {
242 php_http_client_enqueue_t
*enqueue
= php_http_client_enqueued(h
, request
, NULL
);
245 php_error_docref(NULL
, E_WARNING
, "Failed to dequeue request; request not in queue");
248 return h
->ops
->dequeue(h
, enqueue
);
253 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
)
255 zend_llist_element
*el
= NULL
;
258 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
259 if (compare_func((php_http_client_enqueue_t
*) el
->data
, compare_arg
)) {
264 for (el
= h
->requests
.head
; el
; el
= el
->next
) {
265 if (((php_http_client_enqueue_t
*) el
->data
)->request
== compare_arg
) {
270 return el
? (php_http_client_enqueue_t
*) el
->data
: NULL
;
273 ZEND_RESULT_CODE
php_http_client_wait(php_http_client_t
*h
, struct timeval
*custom_timeout
)
276 return h
->ops
->wait(h
, custom_timeout
);
282 int php_http_client_once(php_http_client_t
*h
)
285 return h
->ops
->once(h
);
291 ZEND_RESULT_CODE
php_http_client_exec(php_http_client_t
*h
)
294 return h
->ops
->exec(h
);
300 void php_http_client_reset(php_http_client_t
*h
)
306 zend_llist_clean(&h
->requests
);
307 zend_llist_clean(&h
->responses
);
310 ZEND_RESULT_CODE
php_http_client_setopt(php_http_client_t
*h
, php_http_client_setopt_opt_t opt
, void *arg
)
312 if (h
->ops
->setopt
) {
313 return h
->ops
->setopt(h
, opt
, arg
);
319 ZEND_RESULT_CODE
php_http_client_getopt(php_http_client_t
*h
, php_http_client_getopt_opt_t opt
, void *arg
, void *res_ptr
)
321 if (h
->ops
->getopt
) {
322 return h
->ops
->getopt(h
, opt
, arg
, res_ptr
);
327 static zend_object_handlers php_http_client_object_handlers
;
329 void php_http_client_object_free(zend_object
*object
)
331 php_http_client_object_t
*o
= PHP_HTTP_OBJ(object
, NULL
);
333 php_http_client_free(&o
->client
);
334 php_http_object_method_dtor(&o
->notify
);
335 php_http_object_method_free(&o
->update
);
336 zend_object_std_dtor(object
);
339 php_http_client_object_t
*php_http_client_object_new_ex(zend_class_entry
*ce
, php_http_client_t
*client
)
341 php_http_client_object_t
*o
;
343 o
= ecalloc(1, sizeof(*o
) + zend_object_properties_size(ce
));
344 zend_object_std_init(&o
->zo
, ce
);
345 object_properties_init(&o
->zo
, ce
);
349 o
->zo
.handlers
= &php_http_client_object_handlers
;
354 zend_object
*php_http_client_object_new(zend_class_entry
*ce
)
356 return &php_http_client_object_new_ex(ce
, NULL
)->zo
;
359 static void handle_history(zval
*zclient
, php_http_message_t
*request
, php_http_message_t
*response
)
361 zval new_hist
, old_hist_tmp
, *old_hist
= zend_read_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), 0, &old_hist_tmp
);
362 php_http_message_t
*req_copy
= php_http_message_copy(request
, NULL
);
363 php_http_message_t
*res_copy
= php_http_message_copy(response
, NULL
);
364 php_http_message_t
*zipped
= php_http_message_zip(res_copy
, req_copy
);
365 php_http_message_object_t
*obj
= php_http_message_object_new_ex(php_http_message_get_class_entry(), zipped
);
367 ZVAL_OBJ(&new_hist
, &obj
->zo
);
369 if (Z_TYPE_P(old_hist
) == IS_OBJECT
) {
370 php_http_message_object_prepend(&new_hist
, old_hist
, 1);
373 zend_update_property(php_http_client_class_entry
, zclient
, ZEND_STRL("history"), &new_hist
);
374 zval_ptr_dtor(&new_hist
);
377 static ZEND_RESULT_CODE
handle_response(void *arg
, php_http_client_t
*client
, php_http_client_enqueue_t
*e
, php_http_message_t
**response
)
379 zend_bool dequeue
= 0;
381 php_http_message_t
*msg
;
382 php_http_client_progress_state_t
*progress
;
384 ZVAL_OBJ(&zclient
, &((php_http_client_object_t
*) arg
)->zo
);
386 if ((msg
= *response
)) {
387 php_http_message_object_t
*msg_obj
;
388 zval info
, zresponse
, zrequest
, rec_hist_tmp
;
391 /* ensure the message is of type response (could be uninitialized in case of early error, like DNS) */
392 php_http_message_set_type(msg
, PHP_HTTP_RESPONSE
);
394 if (zend_is_true(zend_read_property(php_http_client_class_entry
, &zclient
, ZEND_STRL("recordHistory"), 0, &rec_hist_tmp
))) {
395 handle_history(&zclient
, e
->request
, *response
);
398 /* hard detach, redirects etc. are in the history */
399 php_http_message_free(&msg
->parent
);
402 msg_obj
= php_http_message_object_new_ex(php_http_get_client_response_class_entry(), msg
);
403 ZVAL_OBJ(&zresponse
, &msg_obj
->zo
);
404 ZVAL_OBJECT(&zrequest
, &((php_http_message_object_t
*) e
->opaque
)->zo
, 1);
406 php_http_message_object_prepend(&zresponse
, &zrequest
, 1);
409 info_ht
= HASH_OF(&info
);
410 php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, e
->request
, &info_ht
);
411 zend_update_property(php_http_get_client_response_class_entry(), &zresponse
, ZEND_STRL("transferInfo"), &info
);
412 zval_ptr_dtor(&info
);
415 zend_llist_add_element(&client
->responses
, &msg_obj
);
417 if (e
->closure
.fci
.size
) {
419 zend_error_handling zeh
;
422 zend_fcall_info_argn(&e
->closure
.fci
, 1, &zresponse
);
423 zend_replace_error_handling(EH_NORMAL
, NULL
, &zeh
);
424 zend_fcall_info_call(&e
->closure
.fci
, &e
->closure
.fcc
, &retval
, NULL
);
425 zend_restore_error_handling(&zeh
);
426 zend_fcall_info_argn(&e
->closure
.fci
, 0);
428 if (Z_TYPE(retval
) == IS_TRUE
) {
431 zval_ptr_dtor(&retval
);
434 zval_ptr_dtor(&zresponse
);
435 zval_ptr_dtor(&zrequest
);
438 if (SUCCESS
== php_http_client_getopt(client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, e
->request
, &progress
)) {
439 progress
->info
= "finished";
440 progress
->finished
= 1;
441 client
->callback
.progress
.func(client
->callback
.progress
.arg
, client
, e
, progress
);
445 php_http_client_dequeue(client
, e
->request
);
451 static void handle_progress(void *arg
, php_http_client_t
*client
, php_http_client_enqueue_t
*e
, php_http_client_progress_state_t
*progress
)
453 zval zclient
, args
[2];
454 php_http_client_object_t
*client_obj
= arg
;
455 zend_error_handling zeh
;
457 ZVAL_OBJECT(&zclient
, &client_obj
->zo
, 1);
458 ZVAL_OBJECT(&args
[0], &((php_http_message_object_t
*) e
->opaque
)->zo
, 1);
459 object_init(&args
[1]);
460 add_property_bool(&args
[1], "started", progress
->started
);
461 add_property_bool(&args
[1], "finished", progress
->finished
);
462 add_property_string(&args
[1], "info", STR_PTR(progress
->info
));
463 add_property_double(&args
[1], "dltotal", progress
->dl
.total
);
464 add_property_double(&args
[1], "dlnow", progress
->dl
.now
);
465 add_property_double(&args
[1], "ultotal", progress
->ul
.total
);
466 add_property_double(&args
[1], "ulnow", progress
->ul
.now
);
468 zend_replace_error_handling(EH_NORMAL
, NULL
, &zeh
);
469 php_http_object_method_call(&client_obj
->notify
, &zclient
, NULL
, 2, args
);
470 zend_restore_error_handling(&zeh
);
472 zval_ptr_dtor(&zclient
);
473 zval_ptr_dtor(&args
[0]);
474 zval_ptr_dtor(&args
[1]);
477 static void response_dtor(void *data
)
479 php_http_message_object_t
*msg_obj
= *(php_http_message_object_t
**) data
;
481 zend_objects_store_del(&msg_obj
->zo
);
484 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_construct
, 0, 0, 0)
485 ZEND_ARG_INFO(0, driver
)
486 ZEND_ARG_INFO(0, persistent_handle_id
)
488 static PHP_METHOD(HttpClient
, __construct
)
490 zend_string
*driver_name
= NULL
, *persistent_handle_name
= NULL
;
491 php_http_client_driver_t
*driver
;
492 php_resource_factory_t
*rf
= NULL
;
493 php_http_client_object_t
*obj
;
496 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|S!S!", &driver_name
, &persistent_handle_name
), invalid_arg
, return);
498 if (!zend_hash_num_elements(&php_http_client_drivers
)) {
499 php_http_throw(unexpected_val
, "No http\\Client drivers available", NULL
);
502 if (!(driver
= php_http_client_driver_get(driver_name
))) {
503 php_http_throw(unexpected_val
, "Failed to locate \"%s\" client request handler", driver_name
? driver_name
->val
: "default");
507 object_init_ex(&os
, spl_ce_SplObjectStorage
);
508 zend_update_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), &os
);
511 if (persistent_handle_name
) {
512 php_persistent_handle_factory_t
*pf
;
514 if ((pf
= php_persistent_handle_concede(NULL
, driver
->client_name
, persistent_handle_name
, NULL
, NULL
))) {
515 rf
= php_persistent_handle_resource_factory_init(NULL
, pf
);
519 obj
= PHP_HTTP_OBJ(NULL
, getThis());
521 php_http_expect(obj
->client
= php_http_client_init(NULL
, driver
->client_ops
, rf
, NULL
), runtime
, return);
523 php_http_object_method_init(&obj
->notify
, getThis(), ZEND_STRL("notify"));
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 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_reset
, 0, 0, 0)
535 static PHP_METHOD(HttpClient
, reset
)
537 php_http_client_object_t
*obj
;
538 php_http_expect(SUCCESS
== zend_parse_parameters_none(), invalid_arg
, return);
540 obj
= PHP_HTTP_OBJ(NULL
, getThis());
543 php_http_client_reset(obj
->client
);
545 RETVAL_ZVAL(getThis(), 1, 0);
548 static HashTable
*combined_options(zval
*client
, zval
*request
)
551 unsigned num_options
= 0;
552 zval z_roptions
, z_options_tmp
, *z_coptions
= zend_read_property(php_http_client_class_entry
, client
, ZEND_STRL("options"), 0, &z_options_tmp
);
554 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
555 num_options
= zend_hash_num_elements(Z_ARRVAL_P(z_coptions
));
557 ZVAL_UNDEF(&z_roptions
);
558 zend_call_method_with_0_params(request
, NULL
, NULL
, "getOptions", &z_roptions
);
559 if (Z_TYPE(z_roptions
) == IS_ARRAY
) {
560 unsigned num
= zend_hash_num_elements(Z_ARRVAL(z_roptions
));
561 if (num
> num_options
) {
565 ALLOC_HASHTABLE(options
);
566 ZEND_INIT_SYMTABLE_EX(options
, num_options
, 0);
567 if (Z_TYPE_P(z_coptions
) == IS_ARRAY
) {
568 array_copy(Z_ARRVAL_P(z_coptions
), options
);
570 if (Z_TYPE(z_roptions
) == IS_ARRAY
) {
571 array_join(Z_ARRVAL(z_roptions
), options
, 0, 0);
573 zval_ptr_dtor(&z_roptions
);
578 static void msg_queue_dtor(php_http_client_enqueue_t
*e
)
580 php_http_message_object_t
*msg_obj
= e
->opaque
;
582 zend_objects_store_del(&msg_obj
->zo
);
583 zend_hash_destroy(e
->options
);
584 FREE_HASHTABLE(e
->options
);
586 if (e
->closure
.fci
.size
) {
587 zval_ptr_dtor(&e
->closure
.fci
.function_name
);
588 if (e
->closure
.fci
.object
) {
589 zend_objects_store_del(e
->closure
.fci
.object
);
594 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enqueue
, 0, 0, 1)
595 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
596 ZEND_ARG_INFO(0, callable
)
598 static PHP_METHOD(HttpClient
, enqueue
)
601 zend_fcall_info fci
= empty_fcall_info
;
602 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
603 php_http_client_object_t
*obj
;
604 php_http_message_object_t
*msg_obj
;
605 php_http_client_enqueue_t q
;
607 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request
, php_http_get_client_request_class_entry(), &fci
, &fcc
), invalid_arg
, return);
609 obj
= PHP_HTTP_OBJ(NULL
, getThis());
610 msg_obj
= PHP_HTTP_OBJ(NULL
, request
);
612 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
613 php_http_throw(bad_method_call
, "Failed to enqueue request; request already in queue", NULL
);
617 q
.request
= msg_obj
->message
;
618 q
.options
= combined_options(getThis(), request
);
619 q
.dtor
= msg_queue_dtor
;
625 Z_TRY_ADDREF(fci
.function_name
);
627 ++GC_REFCOUNT(fci
.object
);
633 php_http_expect(SUCCESS
== php_http_client_enqueue(obj
->client
, &q
), runtime
,
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
)
647 php_http_client_object_t
*obj
;
648 php_http_message_object_t
*msg_obj
;
650 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request
, php_http_get_client_request_class_entry()), invalid_arg
, return);
652 obj
= PHP_HTTP_OBJ(NULL
, getThis());
653 msg_obj
= PHP_HTTP_OBJ(NULL
, request
);
655 if (!php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
656 php_http_throw(bad_method_call
, "Failed to dequeue request; request not in queue", NULL
);
660 php_http_expect(SUCCESS
== php_http_client_dequeue(obj
->client
, msg_obj
->message
), runtime
, return);
662 RETVAL_ZVAL(getThis(), 1, 0);
665 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_requeue
, 0, 0, 1)
666 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
667 ZEND_ARG_INFO(0, callable
)
669 static PHP_METHOD(HttpClient
, requeue
)
672 zend_fcall_info fci
= empty_fcall_info
;
673 zend_fcall_info_cache fcc
= empty_fcall_info_cache
;
674 php_http_client_object_t
*obj
;
675 php_http_message_object_t
*msg_obj
;
676 php_http_client_enqueue_t q
;
678 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request
, php_http_get_client_request_class_entry(), &fci
, &fcc
), invalid_arg
, return);
680 obj
= PHP_HTTP_OBJ(NULL
, getThis());
681 msg_obj
= PHP_HTTP_OBJ(NULL
, request
);
683 if (php_http_client_enqueued(obj
->client
, msg_obj
->message
, NULL
)) {
684 php_http_expect(SUCCESS
== php_http_client_dequeue(obj
->client
, msg_obj
->message
), runtime
, return);
687 q
.request
= msg_obj
->message
;
688 q
.options
= combined_options(getThis(), request
);
689 q
.dtor
= msg_queue_dtor
;
695 Z_TRY_ADDREF(fci
.function_name
);
697 ++GC_REFCOUNT(fci
.object
);
703 php_http_expect(SUCCESS
== php_http_client_enqueue(obj
->client
, &q
), runtime
,
708 RETVAL_ZVAL(getThis(), 1, 0);
711 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_count
, 0, 0, 0)
713 static PHP_METHOD(HttpClient
, count
)
715 zend_long count_mode
= -1;
717 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &count_mode
)) {
718 php_http_client_object_t
*obj
= PHP_HTTP_OBJ(NULL
, getThis());
720 RETVAL_LONG(zend_llist_count(&obj
->client
->requests
));
724 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getResponse
, 0, 0, 0)
725 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
727 static PHP_METHOD(HttpClient
, getResponse
)
729 zval
*zrequest
= NULL
;
730 php_http_client_object_t
*obj
;
732 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &zrequest
, php_http_get_client_request_class_entry()), invalid_arg
, return);
734 obj
= PHP_HTTP_OBJ(NULL
, getThis());
737 /* lookup the response with the request */
738 zend_llist_element
*el
= NULL
;
739 php_http_message_object_t
*req_obj
= PHP_HTTP_OBJ(NULL
, zrequest
);
741 for (el
= obj
->client
->responses
.head
; el
; el
= el
->next
) {
742 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) el
->data
;
744 if (response_obj
->message
->parent
== req_obj
->message
) {
745 RETURN_OBJECT(&response_obj
->zo
, 1);
749 /* not found for the request! */
750 php_http_throw(unexpected_val
, "Could not find response for the request", NULL
);
754 /* pop off the last response */
755 if (obj
->client
->responses
.tail
) {
756 php_http_message_object_t
*response_obj
= *(php_http_message_object_t
**) obj
->client
->responses
.tail
->data
;
760 RETVAL_OBJECT(&response_obj
->zo
, 1);
761 zend_llist_remove_tail(&obj
->client
->responses
);
766 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getHistory
, 0, 0, 0)
768 static PHP_METHOD(HttpClient
, getHistory
)
770 zval zhistory_tmp
, *zhistory
;
772 php_http_expect(SUCCESS
== zend_parse_parameters_none(), invalid_arg
, return);
774 zhistory
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("history"), 0, &zhistory_tmp
);
775 RETVAL_ZVAL(zhistory
, 1, 0);
778 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_send
, 0, 0, 0)
780 static PHP_METHOD(HttpClient
, send
)
782 php_http_client_object_t
*obj
;
784 php_http_expect(SUCCESS
== zend_parse_parameters_none(), invalid_arg
, return);
786 obj
= PHP_HTTP_OBJ(NULL
, getThis());
788 php_http_expect(SUCCESS
== php_http_client_exec(obj
->client
), runtime
, return);
790 RETVAL_ZVAL(getThis(), 1, 0);
793 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_once
, 0, 0, 0)
795 static PHP_METHOD(HttpClient
, once
)
797 if (SUCCESS
== zend_parse_parameters_none()) {
798 php_http_client_object_t
*obj
= PHP_HTTP_OBJ(NULL
, getThis());
800 RETURN_BOOL(0 < php_http_client_once(obj
->client
));
804 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_wait
, 0, 0, 0)
805 ZEND_ARG_INFO(0, timeout
)
807 static PHP_METHOD(HttpClient
, wait
)
811 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|d", &timeout
)) {
812 struct timeval timeout_val
;
813 php_http_client_object_t
*obj
= PHP_HTTP_OBJ(NULL
, getThis());
815 timeout_val
.tv_sec
= (time_t) timeout
;
816 timeout_val
.tv_usec
= PHP_HTTP_USEC(timeout
) % PHP_HTTP_MCROSEC
;
818 RETURN_BOOL(SUCCESS
== php_http_client_wait(obj
->client
, timeout
> 0 ? &timeout_val
: NULL
));
822 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_configure
, 0, 0, 1)
823 ZEND_ARG_ARRAY_INFO(0, settings
, 1)
825 static PHP_METHOD(HttpClient
, configure
)
827 HashTable
*settings
= NULL
;
828 php_http_client_object_t
*obj
;
830 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|H!", &settings
), invalid_arg
, return);
831 obj
= PHP_HTTP_OBJ(NULL
, getThis());
833 php_http_expect(SUCCESS
== php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_CONFIGURATION
, settings
), unexpected_val
, return);
835 RETVAL_ZVAL(getThis(), 1, 0);
838 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enablePipelining
, 0, 0, 0)
839 ZEND_ARG_INFO(0, enable
)
841 static PHP_METHOD(HttpClient
, enablePipelining
)
843 zend_bool enable
= 1;
844 php_http_client_object_t
*obj
;
846 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &enable
), invalid_arg
, return);
848 obj
= PHP_HTTP_OBJ(NULL
, getThis());
850 php_http_expect(SUCCESS
== php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING
, &enable
), unexpected_val
, return);
852 RETVAL_ZVAL(getThis(), 1, 0);
855 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enableEvents
, 0, 0, 0)
856 ZEND_ARG_INFO(0, enable
)
858 static PHP_METHOD(HttpClient
, enableEvents
)
860 zend_bool enable
= 1;
861 php_http_client_object_t
*obj
;
863 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &enable
), invalid_arg
, return);
865 obj
= PHP_HTTP_OBJ(NULL
, getThis());
867 php_http_expect(SUCCESS
== php_http_client_setopt(obj
->client
, PHP_HTTP_CLIENT_OPT_USE_EVENTS
, &enable
), unexpected_val
, return);
869 RETVAL_ZVAL(getThis(), 1, 0);
873 php_http_object_method_t
*cb
;
878 static int notify(zend_object_iterator
*iter
, void *puser
)
881 struct notify_arg
*arg
= puser
;
883 if ((observer
= iter
->funcs
->get_current_data(iter
))) {
884 if (SUCCESS
== php_http_object_method_call(arg
->cb
, observer
, NULL
, arg
->argc
, arg
->args
)) {
885 return ZEND_HASH_APPLY_KEEP
;
888 return ZEND_HASH_APPLY_STOP
;
891 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify
, 0, 0, 0)
892 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 1)
894 static PHP_METHOD(HttpClient
, notify
)
896 zval
*request
= NULL
, *zprogress
= NULL
, observers_tmp
, *observers
;
897 php_http_client_object_t
*client_obj
;
898 struct notify_arg arg
= {NULL
};
900 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|O!o!", &request
, php_http_get_client_request_class_entry(), &zprogress
), invalid_arg
, return);
902 client_obj
= PHP_HTTP_OBJ(NULL
, getThis());
903 observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0, &observers_tmp
);
905 if (Z_TYPE_P(observers
) != IS_OBJECT
) {
906 php_http_throw(unexpected_val
, "Observer storage is corrupted", NULL
);
910 if (client_obj
->update
) {
911 arg
.cb
= client_obj
->update
;
912 ZVAL_COPY(&arg
.args
[0], getThis());
916 ZVAL_COPY(&arg
.args
[1], request
);
920 ZVAL_COPY(&arg
.args
[2], zprogress
);
924 spl_iterator_apply(observers
, notify
, &arg
);
926 zval_ptr_dtor(getThis());
928 zval_ptr_dtor(request
);
931 zval_ptr_dtor(zprogress
);
935 RETVAL_ZVAL(getThis(), 1, 0);
938 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach
, 0, 0, 1)
939 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
941 static PHP_METHOD(HttpClient
, attach
)
943 zval observers_tmp
, *observers
, *observer
, retval
;
944 php_http_client_object_t
*client_obj
;
946 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O", &observer
, spl_ce_SplObserver
), invalid_arg
, return);
948 client_obj
= PHP_HTTP_OBJ(NULL
, getThis());
949 observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0, &observers_tmp
);
951 if (Z_TYPE_P(observers
) != IS_OBJECT
) {
952 php_http_throw(unexpected_val
, "Observer storage is corrupted", NULL
);
956 if (!client_obj
->update
) {
957 client_obj
->update
= php_http_object_method_init(NULL
, observer
, ZEND_STRL("update"));
961 zend_call_method_with_1_params(observers
, NULL
, NULL
, "attach", &retval
, observer
);
962 zval_ptr_dtor(&retval
);
964 RETVAL_ZVAL(getThis(), 1, 0);
967 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach
, 0, 0, 1)
968 ZEND_ARG_OBJ_INFO(0, observer
, SplObserver
, 0)
970 static PHP_METHOD(HttpClient
, detach
)
972 zval observers_tmp
, *observers
, *observer
, retval
;
974 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O", &observer
, spl_ce_SplObserver
), invalid_arg
, return);
976 observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0, &observers_tmp
);
978 if (Z_TYPE_P(observers
) != IS_OBJECT
) {
979 php_http_throw(unexpected_val
, "Observer storage is corrupted", NULL
);
984 zend_call_method_with_1_params(observers
, NULL
, NULL
, "detach", &retval
, observer
);
985 zval_ptr_dtor(&retval
);
987 RETVAL_ZVAL(getThis(), 1, 0);
990 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getObservers
, 0, 0, 0)
992 static PHP_METHOD(HttpClient
, getObservers
)
994 zval observers_tmp
, *observers
;
996 php_http_expect(SUCCESS
== zend_parse_parameters_none(), invalid_arg
, return);
998 observers
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("observers"), 0, &observers_tmp
);
1000 if (Z_TYPE_P(observers
) != IS_OBJECT
) {
1001 php_http_throw(unexpected_val
, "Observer storage is corrupted", NULL
);
1005 RETVAL_ZVAL(observers
, 1, 0);
1008 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getProgressInfo
, 0, 0, 1)
1009 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
1010 ZEND_END_ARG_INFO();
1011 static PHP_METHOD(HttpClient
, getProgressInfo
)
1014 php_http_client_object_t
*obj
;
1015 php_http_message_object_t
*req_obj
;
1016 php_http_client_progress_state_t
*progress
;
1018 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request
, php_http_get_client_request_class_entry()), invalid_arg
, return);
1020 obj
= PHP_HTTP_OBJ(NULL
, getThis());
1021 req_obj
= PHP_HTTP_OBJ(NULL
, request
);
1023 php_http_expect(SUCCESS
== php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, req_obj
->message
, &progress
), unexpected_val
, return);
1025 object_init(return_value
);
1026 add_property_bool(return_value
, "started", progress
->started
);
1027 add_property_bool(return_value
, "finished", progress
->finished
);
1028 add_property_string(return_value
, "info", STR_PTR(progress
->info
));
1029 add_property_double(return_value
, "dltotal", progress
->dl
.total
);
1030 add_property_double(return_value
, "dlnow", progress
->dl
.now
);
1031 add_property_double(return_value
, "ultotal", progress
->ul
.total
);
1032 add_property_double(return_value
, "ulnow", progress
->ul
.now
);
1035 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getTransferInfo
, 0, 0, 1)
1036 ZEND_ARG_OBJ_INFO(0, request
, http
\\Client
\\Request
, 0)
1037 ZEND_END_ARG_INFO();
1038 static PHP_METHOD(HttpClient
, getTransferInfo
)
1042 php_http_client_object_t
*obj
;
1043 php_http_message_object_t
*req_obj
;
1045 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request
, php_http_get_client_request_class_entry()), invalid_arg
, return);
1047 obj
= PHP_HTTP_OBJ(NULL
, getThis());
1048 req_obj
= PHP_HTTP_OBJ(NULL
, request
);
1050 object_init(return_value
);
1051 info
= HASH_OF(return_value
);
1052 php_http_expect(SUCCESS
== php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, req_obj
->message
, &info
), unexpected_val
, return);
1055 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setOptions
, 0, 0, 0)
1056 ZEND_ARG_ARRAY_INFO(0, options
, 1)
1057 ZEND_END_ARG_INFO();
1058 static PHP_METHOD(HttpClient
, setOptions
)
1062 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|a!/", &opts
), invalid_arg
, return);
1064 php_http_client_options_set(getThis(), opts
);
1066 RETVAL_ZVAL(getThis(), 1, 0);
1069 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getOptions
, 0, 0, 0)
1070 ZEND_END_ARG_INFO();
1071 static PHP_METHOD(HttpClient
, getOptions
)
1073 if (SUCCESS
== zend_parse_parameters_none()) {
1074 zval options_tmp
, *options
= zend_read_property(php_http_client_class_entry
, getThis(), ZEND_STRL("options"), 0, &options_tmp
);
1075 RETVAL_ZVAL(options
, 1, 0);
1079 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setSslOptions
, 0, 0, 0)
1080 ZEND_ARG_ARRAY_INFO(0, ssl_option
, 1)
1081 ZEND_END_ARG_INFO();
1082 static PHP_METHOD(HttpClient
, setSslOptions
)
1086 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|a!/", &opts
), invalid_arg
, return);
1088 php_http_client_options_set_subr(getThis(), ZEND_STRL("ssl"), opts
, 1);
1090 RETVAL_ZVAL(getThis(), 1, 0);
1093 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addSslOptions
, 0, 0, 0)
1094 ZEND_ARG_ARRAY_INFO(0, ssl_options
, 1)
1095 ZEND_END_ARG_INFO();
1096 static PHP_METHOD(HttpClient
, addSslOptions
)
1100 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|a!/", &opts
), invalid_arg
, return);
1102 php_http_client_options_set_subr(getThis(), ZEND_STRL("ssl"), opts
, 0);
1104 RETVAL_ZVAL(getThis(), 1, 0);
1107 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getSslOptions
, 0, 0, 0)
1108 ZEND_END_ARG_INFO();
1109 static PHP_METHOD(HttpClient
, getSslOptions
)
1111 if (SUCCESS
== zend_parse_parameters_none()) {
1112 php_http_client_options_get_subr(getThis(), ZEND_STRL("ssl"), return_value
);
1116 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setCookies
, 0, 0, 0)
1117 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1118 ZEND_END_ARG_INFO();
1119 static PHP_METHOD(HttpClient
, setCookies
)
1123 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|a!/", &opts
), invalid_arg
, return);
1125 php_http_client_options_set_subr(getThis(), ZEND_STRL("cookies"), opts
, 1);
1127 RETVAL_ZVAL(getThis(), 1, 0);
1130 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addCookies
, 0, 0, 0)
1131 ZEND_ARG_ARRAY_INFO(0, cookies
, 1)
1132 ZEND_END_ARG_INFO();
1133 static PHP_METHOD(HttpClient
, addCookies
)
1137 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|a!/", &opts
), invalid_arg
, return);
1139 php_http_client_options_set_subr(getThis(), ZEND_STRL("cookies"), opts
, 0);
1141 RETVAL_ZVAL(getThis(), 1, 0);
1144 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getCookies
, 0, 0, 0)
1145 ZEND_END_ARG_INFO();
1146 static PHP_METHOD(HttpClient
, getCookies
)
1148 if (SUCCESS
== zend_parse_parameters_none()) {
1149 php_http_client_options_get_subr(getThis(), ZEND_STRL("cookies"), return_value
);
1153 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableDrivers
, 0, 0, 0)
1154 ZEND_END_ARG_INFO();
1155 static PHP_METHOD(HttpClient
, getAvailableDrivers
)
1157 if (SUCCESS
== zend_parse_parameters_none()) {
1158 array_init(return_value
);
1159 php_http_client_driver_list(Z_ARRVAL_P(return_value
));
1163 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableOptions
, 0, 0, 0)
1164 ZEND_END_ARG_INFO();
1165 static PHP_METHOD(HttpClient
, getAvailableOptions
)
1167 if (SUCCESS
== zend_parse_parameters_none()) {
1168 php_http_client_object_t
*obj
= PHP_HTTP_OBJ(NULL
, getThis());
1170 array_init(return_value
);
1171 php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_AVAILABLE_OPTIONS
, NULL
, &Z_ARRVAL_P(return_value
));
1175 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableConfiguration
, 0, 0, 0)
1176 ZEND_END_ARG_INFO();
1177 static PHP_METHOD(HttpClient
, getAvailableConfiguration
)
1179 if (SUCCESS
== zend_parse_parameters_none()) {
1180 php_http_client_object_t
*obj
= PHP_HTTP_OBJ(NULL
, getThis());
1182 array_init(return_value
);
1183 php_http_client_getopt(obj
->client
, PHP_HTTP_CLIENT_OPT_AVAILABLE_CONFIGURATION
, NULL
, &Z_ARRVAL_P(return_value
));
1187 static zend_function_entry php_http_client_methods
[] = {
1188 PHP_ME(HttpClient
, __construct
, ai_HttpClient_construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
1189 PHP_ME(HttpClient
, reset
, ai_HttpClient_reset
, ZEND_ACC_PUBLIC
)
1190 PHP_ME(HttpClient
, enqueue
, ai_HttpClient_enqueue
, ZEND_ACC_PUBLIC
)
1191 PHP_ME(HttpClient
, dequeue
, ai_HttpClient_dequeue
, ZEND_ACC_PUBLIC
)
1192 PHP_ME(HttpClient
, requeue
, ai_HttpClient_requeue
, ZEND_ACC_PUBLIC
)
1193 PHP_ME(HttpClient
, count
, ai_HttpClient_count
, ZEND_ACC_PUBLIC
)
1194 PHP_ME(HttpClient
, send
, ai_HttpClient_send
, ZEND_ACC_PUBLIC
)
1195 PHP_ME(HttpClient
, once
, ai_HttpClient_once
, ZEND_ACC_PUBLIC
)
1196 PHP_ME(HttpClient
, wait
, ai_HttpClient_wait
, ZEND_ACC_PUBLIC
)
1197 PHP_ME(HttpClient
, getResponse
, ai_HttpClient_getResponse
, ZEND_ACC_PUBLIC
)
1198 PHP_ME(HttpClient
, getHistory
, ai_HttpClient_getHistory
, ZEND_ACC_PUBLIC
)
1199 PHP_ME(HttpClient
, configure
, ai_HttpClient_configure
, ZEND_ACC_PUBLIC
)
1200 PHP_ME(HttpClient
, enablePipelining
, ai_HttpClient_enablePipelining
, ZEND_ACC_PUBLIC
|ZEND_ACC_DEPRECATED
)
1201 PHP_ME(HttpClient
, enableEvents
, ai_HttpClient_enableEvents
, ZEND_ACC_PUBLIC
|ZEND_ACC_DEPRECATED
)
1202 PHP_ME(HttpClient
, notify
, ai_HttpClient_notify
, ZEND_ACC_PUBLIC
)
1203 PHP_ME(HttpClient
, attach
, ai_HttpClient_attach
, ZEND_ACC_PUBLIC
)
1204 PHP_ME(HttpClient
, detach
, ai_HttpClient_detach
, ZEND_ACC_PUBLIC
)
1205 PHP_ME(HttpClient
, getObservers
, ai_HttpClient_getObservers
, ZEND_ACC_PUBLIC
)
1206 PHP_ME(HttpClient
, getProgressInfo
, ai_HttpClient_getProgressInfo
, ZEND_ACC_PUBLIC
)
1207 PHP_ME(HttpClient
, getTransferInfo
, ai_HttpClient_getTransferInfo
, ZEND_ACC_PUBLIC
)
1208 PHP_ME(HttpClient
, setOptions
, ai_HttpClient_setOptions
, ZEND_ACC_PUBLIC
)
1209 PHP_ME(HttpClient
, getOptions
, ai_HttpClient_getOptions
, ZEND_ACC_PUBLIC
)
1210 PHP_ME(HttpClient
, setSslOptions
, ai_HttpClient_setSslOptions
, ZEND_ACC_PUBLIC
)
1211 PHP_ME(HttpClient
, addSslOptions
, ai_HttpClient_addSslOptions
, ZEND_ACC_PUBLIC
)
1212 PHP_ME(HttpClient
, getSslOptions
, ai_HttpClient_getSslOptions
, ZEND_ACC_PUBLIC
)
1213 PHP_ME(HttpClient
, setCookies
, ai_HttpClient_setCookies
, ZEND_ACC_PUBLIC
)
1214 PHP_ME(HttpClient
, addCookies
, ai_HttpClient_addCookies
, ZEND_ACC_PUBLIC
)
1215 PHP_ME(HttpClient
, getCookies
, ai_HttpClient_getCookies
, ZEND_ACC_PUBLIC
)
1216 PHP_ME(HttpClient
, getAvailableDrivers
, ai_HttpClient_getAvailableDrivers
, ZEND_ACC_PUBLIC
|ZEND_ACC_STATIC
)
1217 PHP_ME(HttpClient
, getAvailableOptions
, ai_HttpClient_getAvailableOptions
, ZEND_ACC_PUBLIC
)
1218 PHP_ME(HttpClient
, getAvailableConfiguration
, ai_HttpClient_getAvailableConfiguration
, ZEND_ACC_PUBLIC
)
1219 EMPTY_FUNCTION_ENTRY
1222 PHP_MINIT_FUNCTION(http_client
)
1224 zend_class_entry ce
= {0};
1226 INIT_NS_CLASS_ENTRY(ce
, "http", "Client", php_http_client_methods
);
1227 php_http_client_class_entry
= zend_register_internal_class_ex(&ce
, NULL
);
1228 php_http_client_class_entry
->create_object
= php_http_client_object_new
;
1229 zend_class_implements(php_http_client_class_entry
, 2, spl_ce_SplSubject
, spl_ce_Countable
);
1230 memcpy(&php_http_client_object_handlers
, zend_get_std_object_handlers(), sizeof(zend_object_handlers
));
1231 php_http_client_object_handlers
.offset
= XtOffsetOf(php_http_client_object_t
, zo
);
1232 php_http_client_object_handlers
.free_obj
= php_http_client_object_free
;
1233 php_http_client_object_handlers
.clone_obj
= NULL
;
1234 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("observers"), ZEND_ACC_PRIVATE
);
1235 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("options"), ZEND_ACC_PROTECTED
);
1236 zend_declare_property_null(php_http_client_class_entry
, ZEND_STRL("history"), ZEND_ACC_PROTECTED
);
1237 zend_declare_property_bool(php_http_client_class_entry
, ZEND_STRL("recordHistory"), 0, ZEND_ACC_PUBLIC
);
1239 zend_hash_init(&php_http_client_drivers
, 2, NULL
, php_http_client_driver_hash_dtor
, 1);
1244 PHP_MSHUTDOWN_FUNCTION(http_client
)
1246 zend_hash_destroy(&php_http_client_drivers
);
1255 * vim600: noet sw=4 ts=4 fdm=marker
1256 * vim<600: noet sw=4 ts=4