X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_object.c;h=6307539058e7c76879d78104b3b85dfe0f987994;hp=7567b96d342edeaa482423b378369dca9ad9d9a7;hb=0630e63c82f6e4841577881cdd4b0c3cc4478e4c;hpb=e6d36989f0650bf097b6909c41cdd20a1ffcd6af diff --git a/http_request_object.c b/http_request_object.c index 7567b96..6307539 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -215,6 +215,7 @@ HTTP_END_ARGS; #define http_request_object_declare_default_properties() _http_request_object_declare_default_properties(TSRMLS_C) static inline void _http_request_object_declare_default_properties(TSRMLS_D); +#define OBJ_PROP_CE http_request_object_ce zend_class_entry *http_request_object_ce; zend_function_entry http_request_object_fe[] = { HTTP_REQUEST_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) @@ -518,6 +519,23 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ } http_request_prepare(obj->request, Z_ARRVAL_P(options)); + + /* check if there's a onProgress method and add it as progress callback if one isn't already set */ + if (zend_hash_exists(&Z_OBJCE_P(getThis())->function_table, "onprogress", sizeof("onprogress"))) { + zval **entry, *pcb; + + if ( (Z_TYPE_P(options) != IS_ARRAY) + || (SUCCESS != zend_hash_find(Z_ARRVAL_P(options), "onprogress", sizeof("onprogress"), (void **) &entry) + || (!zval_is_true(*entry)))) { + MAKE_STD_ZVAL(pcb); + array_init(pcb); + ZVAL_ADDREF(getThis()); + add_next_index_zval(pcb, getThis()); + add_next_index_stringl(pcb, "onprogress", lenof("onprogress"), 1); + http_request_set_progress_callback(obj->request, pcb); + zval_ptr_dtor(&pcb); + } + } } return status;