- fixed message chain order in HttpRequest::getHistory()
authorMichael Wallner <mike@php.net>
Thu, 16 Feb 2006 09:09:23 +0000 (09:09 +0000)
committerMichael Wallner <mike@php.net>
Thu, 16 Feb 2006 09:09:23 +0000 (09:09 +0000)
# no need to reverse there; I got tricked by my own toString() impl

http_message_api.c
http_request_object.c
package2.xml
php_http.h
tests/HttpRequest_007.phpt

index 399650ea591975a4fdf998ee686e11923113e359..915469248187e0119070235d60d6956883545bea 100644 (file)
@@ -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;
 }
index 35c66200278a4eed9233cdf02224b4b2c736bdb1..46b805a262b9e26746eccbd34408a0b3ad1acd08 100644 (file)
@@ -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);
index e805ba192ac902f3cb9fc76fcaf1dc2c277f502e..6d63ec71506efcd8ff25609da67425419f8bf1bc 100644 (file)
@@ -37,7 +37,7 @@ HttpResponse
  </lead>
  <date>2006-00-00</date>
  <version>
-  <release>0.23.1</release>
+  <release>0.23.2</release>
   <api>0.23.0</api>
  </version>
  <stability>
@@ -46,7 +46,7 @@ HttpResponse
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed http_parse_cookie(), really.
+* Fixed message chain order in HttpRequest::getHistory().
 ]]></notes>
  <contents>
   <dir name="/">
index 6df82088bbae7cb3ed25aade59d8dde1cd900ffe..94bf26f382edf6b633694c222ea10fdcdef5394c 100644 (file)
@@ -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"
index 96160af3db1cb89d2cf16c5754b08f4b41094274..1f31404af3f6cdccbfbfab3da77d5d76423a3758 100644 (file)
@@ -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
 
 <?php
 echo "-TEST\n";
@@ -41,13 +40,14 @@ echo "Done\n";
 ?>
 
 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
 
 <?php
 echo "-TEST\n";
@@ -63,4 +63,3 @@ echo "Done\n";
 
 "
 Done
-