From: Michael Wallner Date: Mon, 13 Jun 2005 15:24:45 +0000 (+0000) Subject: - sanitize retreival of response info X-Git-Tag: RELEASE_0_9_0~30 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ab29a31d9129a377cdd664de08cb2bf86a72be1b;p=m6w6%2Fext-http - sanitize retreival of response info --- diff --git a/http_methods.c b/http_methods.c index ebb892a..cf1fb9e 100644 --- a/http_methods.c +++ b/http_methods.c @@ -2125,15 +2125,13 @@ PHP_METHOD(HttpRequest, send) } if (SUCCESS == (status = http_request_object_requesthandler(obj, getThis(), &body))) { - zval *info = GET_PROP(obj, responseInfo); - status = http_request_exec(obj->ch, Z_ARRVAL_P(info)); - SET_PROP(obj, responseInfo, info); + status = http_request_exec(obj->ch, NULL); } http_request_body_dtor(&body); /* final data handling */ if (SUCCESS == status) { - status = http_request_object_responsehandler(obj, getThis(), NULL); + status = http_request_object_responsehandler(obj, getThis()); } SET_EH_NORMAL(); diff --git a/http_request_api.c b/http_request_api.c index 49b699b..ca91a28 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -48,6 +48,14 @@ ZEND_EXTERN_MODULE_GLOBALS(http) #if LIBCURL_VERSION_NUM < 0x070c00 # define curl_easy_strerror(code) HTTP_G(request).error +# ifndef curl_multi_strerror + static char *curl_multi_strerror(int code) + { + char message[256] = {0}; + snprintf(message, 255, "Unknown HttpRequestPool error (curl multi code: %d)", code); + return http_request_data_copy(COPY_STRING, message); + } +#endif #endif #define HTTP_CURL_INFO(I) HTTP_CURL_INFO_EX(I, I) @@ -973,7 +981,7 @@ void _http_request_pool_responsehandler(zval **req TSRMLS_DC) #if HTTP_DEBUG_REQPOOLS fprintf(stderr, "Fetching data from request %p of pool %p\n", obj, obj->pool); #endif - http_request_object_responsehandler(obj, *req, NULL); + http_request_object_responsehandler(obj, *req); } /* }}} */ diff --git a/http_request_object.c b/http_request_object.c index 1c99c8c..2f51ec2 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -292,7 +292,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ return status; } -STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this_ptr, HashTable *info TSRMLS_DC) +STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this_ptr TSRMLS_DC) { http_message *msg; @@ -301,7 +301,7 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this if (msg = http_message_parse(PHPSTR_VAL(&obj->response), PHPSTR_LEN(&obj->response))) { char *body; size_t body_len; - zval *headers, *message = GET_PROP(obj, responseMessage), *resp = GET_PROP(obj, responseData); + zval *headers, *message, *resp = GET_PROP(obj, responseData), *info = GET_PROP(obj, responseInfo); UPD_PROP(obj, long, responseCode, msg->info.response.code); @@ -314,14 +314,13 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this add_assoc_zval(resp, "headers", headers); add_assoc_stringl(resp, "body", body, body_len, 0); - //zval_dtor(&message); + MAKE_STD_ZVAL(message); Z_TYPE_P(message) = IS_OBJECT; message->value.obj = http_message_object_from_msg(msg); SET_PROP(obj, responseMessage, message); - if (info) { - http_request_info(obj->ch, info); - } + http_request_info(obj->ch, Z_ARRVAL_P(info)); + SET_PROP(obj, responseInfo, info); return SUCCESS; } diff --git a/php_http_request_object.h b/php_http_request_object.h index e223785..be9fac0 100644 --- a/php_http_request_object.h +++ b/php_http_request_object.h @@ -48,8 +48,8 @@ extern void _http_request_object_free(zend_object *object TSRMLS_DC); #define http_request_object_requesthandler(req, this, body) _http_request_object_requesthandler((req), (this), (body) TSRMLS_CC) extern STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ptr, http_request_body *body TSRMLS_DC); -#define http_request_object_responsehandler(req, this, info) _http_request_object_responsehandler((req), (this), (info) TSRMLS_CC) -extern STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this_ptr, HashTable *info TSRMLS_DC); +#define http_request_object_responsehandler(req, this) _http_request_object_responsehandler((req), (this) TSRMLS_CC) +extern STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this_ptr TSRMLS_DC); PHP_METHOD(HttpRequest, __construct); PHP_METHOD(HttpRequest, __destruct);