X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client.h;h=fb4a600027017be46e15e93c616585be0f5559cb;hp=12e557eef59cc9dfa6cad73b5e286c3234840c56;hb=7566d9549758b56d37b86473feb16248378744e0;hpb=a18e662d5ff2c4e7051e028f8002dbba720cccd6 diff --git a/php_http_client.h b/php_http_client.h index 12e557e..fb4a600 100644 --- a/php_http_client.h +++ b/php_http_client.h @@ -38,7 +38,6 @@ typedef struct php_http_client_progress_callback { void (*intern)(php_http_client_progress_state_t* TSRMLS_DC); } func; unsigned type:1; - unsigned pass_state:1; } php_http_client_progress_callback_t; typedef struct php_http_client_progress { @@ -69,32 +68,12 @@ static inline void php_http_client_progress_notify(php_http_client_progress_t *p with_error_handling(EH_NORMAL, NULL) { switch (progress->callback->type) { case PHP_HTTP_CLIENT_PROGRESS_CALLBACK_USER: - if (progress->callback->pass_state) { - zval *param; - - MAKE_STD_ZVAL(param); - array_init(param); - add_assoc_bool(param, "started", progress->state.started); - add_assoc_bool(param, "finished", progress->state.finished); - add_assoc_string(param, "info", estrdup(progress->state.info), 0); - add_assoc_double(param, "dltotal", progress->state.dl.total); - add_assoc_double(param, "dlnow", progress->state.dl.now); - add_assoc_double(param, "ultotal", progress->state.ul.total); - add_assoc_double(param, "ulnow", progress->state.ul.now); - - progress->in_cb = 1; - call_user_function(EG(function_table), NULL, progress->callback->func.user, &retval, 1, ¶m TSRMLS_CC); - progress->in_cb = 0; - - zval_ptr_dtor(¶m); - } else { - progress->in_cb = 1; - call_user_function(EG(function_table), NULL, progress->callback->func.user, &retval, 0, NULL TSRMLS_CC); - progress->in_cb = 0; - } + progress->in_cb = 1; + call_user_function(EG(function_table), NULL, progress->callback->func.user, &retval, 0, NULL TSRMLS_CC); + progress->in_cb = 0; break; case PHP_HTTP_CLIENT_PROGRESS_CALLBACK_INTERN: - progress->callback->func.intern(progress->callback->pass_state ? &progress->state : NULL TSRMLS_CC); + progress->callback->func.intern(&progress->state TSRMLS_CC); break; default: break; @@ -144,9 +123,16 @@ typedef struct php_http_client { void *ctx; php_http_resource_factory_t *rf; php_http_client_ops_t *ops; - php_http_message_parser_t *parser; - php_http_message_t *message; - php_http_buffer_t *buffer; + struct { + php_http_message_parser_t *parser; + php_http_message_t *message; + php_http_buffer_t *buffer; + } request; + struct { + php_http_message_parser_t *parser; + php_http_message_t *message; + php_http_buffer_t *buffer; + } response; #ifdef ZTS void ***ts; #endif @@ -166,21 +152,20 @@ typedef struct php_http_client_object { php_http_client_t *client; } php_http_client_object_t; -extern zend_class_entry *php_http_client_class_entry; -extern zend_function_entry php_http_client_method_entry[]; - -extern zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC); -extern zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_client_t *r, php_http_client_object_t **ptr TSRMLS_DC); -extern zend_object_value php_http_client_object_clone(zval *zobject TSRMLS_DC); -extern void php_http_client_object_free(void *object TSRMLS_DC); +zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC); +zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_client_t *r, php_http_client_object_t **ptr TSRMLS_DC); +zend_object_value php_http_client_object_clone(zval *zobject TSRMLS_DC); +void php_http_client_object_free(void *object TSRMLS_DC); -extern zend_object_handlers *php_http_client_get_object_handlers(void); +zend_class_entry *php_http_client_get_class_entry(void); +zend_object_handlers *php_http_client_get_object_handlers(void); -extern STATUS php_http_client_object_handle_request(zval *zclient, zval **zreq TSRMLS_DC); -extern STATUS php_http_client_object_handle_response(zval *zclient TSRMLS_DC); +STATUS php_http_client_object_handle_request(zval *zclient, zval **zreq TSRMLS_DC); +STATUS php_http_client_object_handle_response(zval *zclient TSRMLS_DC); -extern STATUS php_http_client_object_requesthandler(php_http_client_object_t *obj, zval *this_ptr, char **meth, char **url, php_http_message_body_t **body TSRMLS_DC); -extern STATUS php_http_client_object_responsehandler(php_http_client_object_t *obj, zval *this_ptr TSRMLS_DC); +void php_http_client_options_set(zval *this_ptr, zval *opts TSRMLS_DC); +void php_http_client_options_set_subr(zval *this_ptr, char *key, size_t len, zval *opts, int overwrite TSRMLS_DC); +void php_http_client_options_get_subr(zval *this_ptr, char *key, size_t len, zval *return_value TSRMLS_DC); PHP_METHOD(HttpClient, __construct); PHP_METHOD(HttpClient, getObservers); @@ -203,6 +188,7 @@ PHP_METHOD(HttpClient, flushCookies); PHP_METHOD(HttpClient, setRequest); PHP_METHOD(HttpClient, getRequest); PHP_METHOD(HttpClient, send); +PHP_METHOD(HttpClient, request); PHP_METHOD(HttpClient, getResponseMessage); PHP_METHOD(HttpClient, getRequestMessage); PHP_METHOD(HttpClient, getHistory); @@ -210,7 +196,7 @@ PHP_METHOD(HttpClient, clearHistory); PHP_METHOD(HttpClient, getResponseMessageClass); PHP_METHOD(HttpClient, setResponseMessageClass); -extern PHP_MINIT_FUNCTION(http_client); +PHP_MINIT_FUNCTION(http_client); #endif