- backport fix for bug #11359 HttpMessage::toMessageTypeObject() does not populate...
authorMichael Wallner <mike@php.net>
Tue, 19 Jun 2007 20:35:48 +0000 (20:35 +0000)
committerMichael Wallner <mike@php.net>
Tue, 19 Jun 2007 20:35:48 +0000 (20:35 +0000)
http_message_object.c
package.xml
package2.xml
php_http.h

index c5a219f49a303144e1c8f9b333d8a07271f6615b..379d37592dcf91881eb31ed906f8e1480dffb40f 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "zend_interfaces.h"
 #include "ext/standard/url.h"
+#include "php_variables.h"
 
 #include "php_http_api.h"
 #include "php_http_send_api.h"
@@ -1235,21 +1236,24 @@ PHP_METHOD(HttpMessage, toMessageTypeObject)
 #ifdef HTTP_HAVE_CURL
                                int method;
                                char *url;
-                               zval body, *array, *headers, *host = http_message_header(obj->message, "Host");
-                               php_url hurl, *purl = php_url_parse(obj->message->http.info.request.url);
+                               zval post, body, *array, *headers, *host = http_message_header(obj->message, "Host");
+                               php_url hurl, *purl = php_url_parse(STR_PTR(obj->message->http.info.request.url));
                                
                                MAKE_STD_ZVAL(array);
                                array_init(array);
                                
                                memset(&hurl, 0, sizeof(php_url));
-                               hurl.host = host ? Z_STRVAL_P(host) : NULL;
-                               zval_ptr_dtor(&host);
+                               if (host) {
+                                       hurl.host = Z_STRVAL_P(host);
+                                       zval_ptr_dtor(&host);
+                               }
                                http_build_url(HTTP_URL_REPLACE, purl, &hurl, NULL, &url, NULL);
                                php_url_free(purl);
                                add_assoc_string(array, "url", url, 0);
                                
-                               if (    (method = http_request_method_exists(1, 0, obj->message->http.info.request.method)) ||
-                                               (method = http_request_method_register(obj->message->http.info.request.method, strlen(obj->message->http.info.request.method)))) {
+                               if (    obj->message->http.info.request.method &&
+                                                       ((method = http_request_method_exists(1, 0, obj->message->http.info.request.method)) ||
+                                                       (method = http_request_method_register(obj->message->http.info.request.method, strlen(obj->message->http.info.request.method))))) {
                                        add_assoc_long(array, "method", method);
                                }
                                
@@ -1266,9 +1270,21 @@ PHP_METHOD(HttpMessage, toMessageTypeObject)
                                zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setoptions", NULL, array);
                                zval_ptr_dtor(&array);
                                
-                               INIT_PZVAL(&body);
-                               ZVAL_STRINGL(&body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message), 0);
-                               zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setrawpostdata", NULL, &body);
+                               if (PHPSTR_VAL(obj->message) && PHPSTR_LEN(obj->message)) {
+                                       INIT_PZVAL(&body);
+                                       ZVAL_STRINGL(&body, PHPSTR_VAL(obj->message), PHPSTR_LEN(obj->message), 0);
+                                       if (method != HTTP_POST) {
+                                               zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setbody", NULL, &body);
+                                       } else {
+                                               INIT_PZVAL(&post);
+                                               array_init(&post);
+                                               
+                                               zval_copy_ctor(&body);
+                                               sapi_module.treat_data(PARSE_STRING, Z_STRVAL(body), &post TSRMLS_CC);
+                                               zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setpostfields", NULL, &post);
+                                               zval_dtor(&body);
+                                       }
+                               }
 #else
                                http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpRequest (missing curl support)");
 #endif
index ca0a78540c5e97cc479b08b851c5b71c51fa0e74..d84f09d65c285af03b24cb366d49e385e793cc1c 100644 (file)
@@ -23,11 +23,11 @@ support. Parallel requests are available for PHP 5 and greater.
   </maintainer>
   </maintainers>
  <release>
-  <version>1.5.3</version>
-  <date>2007-04-25</date>
+  <version>1.5.4</version>
+  <date>2007-06-19</date>
   <license>BSD, revised</license>
   <state>stable</state>
-  <notes>* Fixed crashes with repeated registering/unregisitering of request methods (noticed by Andreas Weber)
+  <notes>* Fixed bug #11359 HttpMessage::toMessageTypeObject() does not populate POST fields
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.3"/>
index c687f2b0a21765ac23b8f19f209265fb7a68c260..b5c631f27ad7df2ef65d1293cc04828bbb75645a 100644 (file)
@@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2007-04-25</date>
+ <date>2007-06-19</date>
  <version>
-  <release>1.5.3</release>
+  <release>1.5.4</release>
   <api>1.5.0</api>
  </version>
  <stability>
@@ -39,7 +39,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed crashes with repeated registering/unregisitering of request methods (noticed by Andreas Weber)
+* Fixed bug #11359 HttpMessage::toMessageTypeObject() does not populate POST fields
 ]]></notes>
  <contents>
   <dir name="/">
index 08f7bc8382a16488c87ad5c6e0eccb6568043bc5..a5c9856d15ecde5f53201079dd96a09ab20a1c63 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_EXT_HTTP_VERSION "1.5.3"
+#define PHP_EXT_HTTP_VERSION "1.5.4"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"