- sanitize retreival of response info
authorMichael Wallner <mike@php.net>
Mon, 13 Jun 2005 15:24:45 +0000 (15:24 +0000)
committerMichael Wallner <mike@php.net>
Mon, 13 Jun 2005 15:24:45 +0000 (15:24 +0000)
http_methods.c
http_request_api.c
http_request_object.c
php_http_request_object.h

index ebb892a6a73ac3c86eaabfadd405074b63d55060..cf1fb9e0ebd96c812e06eb5ebe84ab6576c302e0 100644 (file)
@@ -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();
index 49b699b04dba59a7fea3b83827273d72f5b2a2a7..ca91a28cae071e142c99430bbfce41a5ceca5a7b 100644 (file)
@@ -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);
 }
 /* }}} */
 
index 1c99c8c215e90231fc8a5c17634db91bf7bc8e1b..2f51ec2f46d84899557a9ce1fefd34711afdf430 100644 (file)
@@ -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;
        }
index e22378548a635c66a983663f84254f24f5d66d2d..be9fac0b772aad593ad5ac07961f83d8c694e5ad 100644 (file)
@@ -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);