From: Michael Wallner Date: Thu, 16 Feb 2006 09:09:23 +0000 (+0000) Subject: - fixed message chain order in HttpRequest::getHistory() X-Git-Tag: RELEASE_0_24_0~9 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=b22d34f60b6694a8fed24cff66a28fd638309928 - fixed message chain order in HttpRequest::getHistory() # no need to reverse there; I got tricked by my own toString() impl --- diff --git a/http_message_api.c b/http_message_api.c index 399650e..9154692 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -404,9 +404,7 @@ PHP_HTTP_API http_message *_http_message_reverse(http_message *msg) PHP_HTTP_API http_message *_http_message_interconnect(http_message *m1, http_message *m2) { - if (!m1) { - return NULL; - } else if (m2) { + if (m1 && m2) { int i = 0, c1, c2; http_message *t1 = m1, *t2 = m2, *p1, *p2; @@ -424,6 +422,8 @@ PHP_HTTP_API http_message *_http_message_interconnect(http_message *m1, http_mes t1 = p1; t2 = p2; } + } else if (!m1 && m2) { + m1 = m2; } return m1; } diff --git a/http_request_object.c b/http_request_object.c index 35c6620..46b805a 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -572,28 +572,17 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this zval *headers, *message, *resp; if (zval_is_true(GET_PROP(recordHistory))) { - /* we need to act like a zipper, as we'll receive - * the requests and the responses in separate chains - * for redirects - */ + zval *hist, *history = GET_PROP(history); http_message *response = http_message_parse(PHPSTR_VAL(&obj->request->conv.response), PHPSTR_LEN(&obj->request->conv.response)); http_message *request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)); - if (response && request) { - zval *hist, *history = GET_PROP(history); - http_message *hist_msg = http_message_reverse(http_message_interconnect(response, request)); - - MAKE_STD_ZVAL(hist); - ZVAL_OBJVAL(hist, http_message_object_new_ex(http_message_object_ce, hist_msg, NULL), 0); - if (Z_TYPE_P(history) == IS_OBJECT) { - http_message_object_prepend(hist, history); - } - SET_PROP(history, hist); - zval_ptr_dtor(&hist); - } else { - http_message_free(&response); - http_message_free(&request); + MAKE_STD_ZVAL(hist); + ZVAL_OBJVAL(hist, http_message_object_new_ex(http_message_object_ce, http_message_interconnect(response, request), NULL), 0); + if (Z_TYPE_P(history) == IS_OBJECT) { + http_message_object_prepend(hist, history); } + SET_PROP(history, hist); + zval_ptr_dtor(&hist); } UPD_PROP(long, responseCode, msg->http.info.response.code); diff --git a/package2.xml b/package2.xml index e805ba1..6d63ec7 100644 --- a/package2.xml +++ b/package2.xml @@ -37,7 +37,7 @@ HttpResponse 2006-00-00 - 0.23.1 + 0.23.2 0.23.0 @@ -46,7 +46,7 @@ HttpResponse BSD, revised diff --git a/php_http.h b/php_http.h index 6df8208..94bf26f 100644 --- a/php_http.h +++ b/php_http.h @@ -15,7 +15,7 @@ #ifndef PHP_EXT_HTTP_H #define PHP_EXT_HTTP_H -#define PHP_EXT_HTTP_VERSION "0.23.1" +#define PHP_EXT_HTTP_VERSION "0.23.2" #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/tests/HttpRequest_007.phpt b/tests/HttpRequest_007.phpt index 96160af..1f31404 100644 --- a/tests/HttpRequest_007.phpt +++ b/tests/HttpRequest_007.phpt @@ -19,14 +19,13 @@ echo "Done\n"; ?> --EXPECTF-- %sTEST -string(%d) "HTTP/1.1 200 OK -Date: %s -Server: Apache/%s -X-Powered-By: PHP/5%s -Vary: Accept-Encoding -Content-Type: text/html -X-Original-Transfer-Encoding: chunked +string(%d) "PUT /.print_put.php5 HTTP/1.1 +User-Agent: PECL::HTTP/%s +Host: dev.iworks.at +Accept: */* +Content-Type: text/plain Content-Length: 281 +Expect: 100-continue HTTP/1.1 100 Continue -PUT /.print_put.php5 HTTP/1.1 -User-Agent: PECL::HTTP/%s -Host: dev.iworks.at -Accept: */* -Content-Type: text/plain +HTTP/1.1 200 OK +Date: %s +Server: %s +X-Powered-By: %s +Vary: Accept-Encoding +Content-Type: text/html +X-Original-Transfer-Encoding: chunked Content-Length: 281 -Expect: 100-continue