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 #ifndef PHP_HTTP_CLIENT_H
14 #define PHP_HTTP_CLIENT_H
16 typedef enum php_http_client_setopt_opt
{
17 PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING
,
18 PHP_HTTP_CLIENT_OPT_USE_EVENTS
,
19 } php_http_client_setopt_opt_t
;
21 typedef enum php_http_client_getopt_opt
{
22 PHP_HTTP_CLIENT_OPT_PROGRESS_INFO
, /* php_http_client_progress_state_t** */
23 PHP_HTTP_CLIENT_OPT_TRANSFER_INFO
, /* HashTable* */
24 } php_http_client_getopt_opt_t
;
26 typedef struct php_http_client_enqueue
{
27 php_http_message_t
*request
; /* unique */
29 void (*dtor
)(struct php_http_client_enqueue
*);
33 zend_fcall_info_cache fcc
;
35 } php_http_client_enqueue_t
;
37 typedef struct php_http_client
*(*php_http_client_init_func_t
)(struct php_http_client
*p
, void *init_arg
);
38 typedef struct php_http_client
*(*php_http_client_copy_func_t
)(struct php_http_client
*from
, struct php_http_client
*to
);
39 typedef void (*php_http_client_dtor_func_t
)(struct php_http_client
*p
);
40 typedef void (*php_http_client_reset_func_t
)(struct php_http_client
*p
);
41 typedef ZEND_RESULT_CODE (*php_http_client_exec_func_t
)(struct php_http_client
*p
);
42 typedef int (*php_http_client_once_func_t
)(struct php_http_client
*p
);
43 typedef ZEND_RESULT_CODE (*php_http_client_wait_func_t
)(struct php_http_client
*p
, struct timeval
*custom_timeout
);
44 typedef ZEND_RESULT_CODE (*php_http_client_enqueue_func_t
)(struct php_http_client
*p
, php_http_client_enqueue_t
*enqueue
);
45 typedef ZEND_RESULT_CODE (*php_http_client_dequeue_func_t
)(struct php_http_client
*p
, php_http_client_enqueue_t
*enqueue
);
46 typedef ZEND_RESULT_CODE (*php_http_client_setopt_func_t
)(struct php_http_client
*p
, php_http_client_setopt_opt_t opt
, void *arg
);
47 typedef ZEND_RESULT_CODE (*php_http_client_getopt_func_t
)(struct php_http_client
*h
, php_http_client_getopt_opt_t opt
, void *arg
, void **res
);
49 typedef struct php_http_client_ops
{
50 php_resource_factory_ops_t
*rsrc
;
51 php_http_client_init_func_t init
;
52 php_http_client_copy_func_t copy
;
53 php_http_client_dtor_func_t dtor
;
54 php_http_client_reset_func_t reset
;
55 php_http_client_exec_func_t exec
;
56 php_http_client_wait_func_t wait
;
57 php_http_client_once_func_t once
;
58 php_http_client_enqueue_func_t enqueue
;
59 php_http_client_dequeue_func_t dequeue
;
60 php_http_client_setopt_func_t setopt
;
61 php_http_client_getopt_func_t getopt
;
62 } php_http_client_ops_t
;
64 typedef struct php_http_client_driver
{
65 zend_string
*driver_name
;
66 zend_string
*client_name
;
67 zend_string
*request_name
;
68 php_http_client_ops_t
*client_ops
;
69 } php_http_client_driver_t
;
71 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_driver_add(php_http_client_driver_t
*driver
);
72 PHP_HTTP_API php_http_client_driver_t
*php_http_client_driver_get(zend_string
*name
);
74 typedef struct php_http_client_progress_state
{
86 } php_http_client_progress_state_t
;
88 typedef ZEND_RESULT_CODE (*php_http_client_response_callback_t
)(void *arg
, struct php_http_client
*client
, php_http_client_enqueue_t
*e
, php_http_message_t
**response
);
89 typedef void (*php_http_client_progress_callback_t
)(void *arg
, struct php_http_client
*client
, php_http_client_enqueue_t
*e
, php_http_client_progress_state_t
*state
);
91 typedef struct php_http_client
{
93 php_resource_factory_t
*rf
;
94 php_http_client_ops_t
*ops
;
98 php_http_client_response_callback_t func
;
102 php_http_client_progress_callback_t func
;
108 zend_llist responses
;
111 PHP_HTTP_API zend_class_entry
*php_http_client_class_entry
;
113 typedef struct php_http_client_object
{
114 php_http_client_t
*client
;
115 php_http_object_method_t
*update
;
116 php_http_object_method_t notify
;
119 } php_http_client_object_t
;
121 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
);
122 PHP_HTTP_API php_http_client_t
*php_http_client_copy(php_http_client_t
*from
, php_http_client_t
*to
);
123 PHP_HTTP_API
void php_http_client_dtor(php_http_client_t
*h
);
124 PHP_HTTP_API
void php_http_client_free(php_http_client_t
**h
);
126 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_enqueue(php_http_client_t
*h
, php_http_client_enqueue_t
*enqueue
);
127 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_dequeue(php_http_client_t
*h
, php_http_message_t
*request
);
129 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_wait(php_http_client_t
*h
, struct timeval
*custom_timeout
);
130 PHP_HTTP_API
int php_http_client_once(php_http_client_t
*h
);
132 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_exec(php_http_client_t
*h
);
133 PHP_HTTP_API
void php_http_client_reset(php_http_client_t
*h
);
135 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_setopt(php_http_client_t
*h
, php_http_client_setopt_opt_t opt
, void *arg
);
136 PHP_HTTP_API ZEND_RESULT_CODE
php_http_client_getopt(php_http_client_t
*h
, php_http_client_getopt_opt_t opt
, void *arg
, void *res_ptr
);
138 typedef int (*php_http_client_enqueue_cmp_func_t
)(php_http_client_enqueue_t
*cmp
, void *arg
);
139 /* compare with request message pointer if compare_func is NULL */
140 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
);
142 PHP_MINIT_FUNCTION(http_client
);
143 PHP_MSHUTDOWN_FUNCTION(http_client
);
152 * vim600: noet sw=4 ts=4 fdm=marker
153 * vim<600: noet sw=4 ts=4