Merge branch 'R_2_0'
authorMichael Wallner <mike@php.net>
Wed, 9 Jul 2014 12:41:03 +0000 (14:41 +0200)
committerMichael Wallner <mike@php.net>
Wed, 9 Jul 2014 12:41:03 +0000 (14:41 +0200)
20 files changed:
php_http_client.c
php_http_env.c
php_http_message.c
tests/bug66388.phpt
tests/client002.phpt
tests/client003.phpt
tests/client004.phpt
tests/client005.phpt
tests/client006.phpt
tests/client007.phpt
tests/client008.phpt
tests/client009.phpt
tests/client011.phpt
tests/client012.phpt
tests/client013.phpt
tests/clientresponse001.phpt
tests/clientresponse002.phpt
tests/clientresponse003.phpt
tests/envresponse004.phpt
tests/skipif.inc

index 8a166fc23acb5d345064dd5c2e586879d63ea1f6..f96164bbba08ad449733b745503149948412de03 100644 (file)
@@ -377,6 +377,7 @@ static void handle_history(zval *zclient, php_http_message_t *request, php_http_
 
 static STATUS handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response)
 {
+       zend_bool dequeue = 0;
        zval zclient;
        php_http_message_t *msg;
        php_http_client_progress_state_t *progress;
@@ -430,8 +431,8 @@ static STATUS handle_response(void *arg, php_http_client_t *client, php_http_cli
                        zend_fcall_info_argn(&e->closure.fci TSRMLS_CC, 0);
 
                        if (retval) {
-                               if (Z_TYPE_P(retval) == IS_BOOL && Z_BVAL_P(retval)) {
-                                       php_http_client_dequeue(client, e->request);
+                               if (Z_TYPE_P(retval) == IS_BOOL) {
+                                       dequeue = Z_BVAL_P(retval);
                                }
                                zval_ptr_dtor(&retval);
                        }
@@ -447,6 +448,10 @@ static STATUS handle_response(void *arg, php_http_client_t *client, php_http_cli
                client->callback.progress.func(client->callback.progress.arg, client, e, progress);
        }
 
+       if (dequeue) {
+               php_http_client_dequeue(client, e->request);
+       }
+
        return SUCCESS;
 }
 
index 30ee32d7c68b3341aeaeb24c909b102537caccdf..10d54fe4019a5a0472ffc95b1c6bfe1758964279 100644 (file)
@@ -715,6 +715,7 @@ static PHP_METHOD(HttpEnv, getRequestBody)
 
        body = php_http_env_get_request_body(TSRMLS_C);
        if (SUCCESS == php_http_new(&ov, class_entry, (php_http_new_t) php_http_message_body_object_new_ex, php_http_message_body_class_entry, body, NULL TSRMLS_CC)) {
+               php_http_message_body_addref(body);
                RETVAL_OBJVAL(ov, 0);
        }
 }
@@ -968,18 +969,18 @@ static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler)
 #endif
 
        if (json_len) {
-               zval_dtor(zarg);
-               ZVAL_NULL(zarg);
-               php_json_decode(zarg, json_str, json_len, 1, PG(max_input_nesting_level) TSRMLS_CC);
+               zval zjson;
+
+               INIT_ZVAL(zjson);
+               php_json_decode(&zjson, json_str, json_len, 1, PG(max_input_nesting_level) TSRMLS_CC);
+               if (Z_TYPE(zjson) != IS_NULL) {
+                       zval_dtor(zarg);
+                       ZVAL_COPY_VALUE(zarg, (&zjson));
+               }
        }
 #if PHP_VERSION_ID >= 50600
        STR_FREE(json_str);
 #endif
-
-       /* always let $_POST be array() */
-       if (Z_TYPE_P(zarg) == IS_NULL) {
-               array_init(zarg);
-       }
 }
 
 static void php_http_env_register_json_handler(TSRMLS_D)
index 8c1f40ccbd077da096d6037d02a298a78014ceae..9432ae953f7c7a8fd5e2bce46401fd080f207628 100644 (file)
@@ -772,7 +772,9 @@ STATUS php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval
        }
 
        body_obj = zend_object_store_get_object(zbody TSRMLS_CC);
-
+       if (!body_obj->body) {
+               body_obj->body = php_http_message_body_init(NULL, NULL TSRMLS_CC);
+       }
        if (msg_obj->body) {
                zend_objects_store_del_ref_by_handle(msg_obj->body->zv.handle TSRMLS_CC);
        }
index bc624dc97bb1d224c51caa8e22c94178b5db811b..9f9c95e9ed1aa723fe3b41c717e0850b9715f10c 100644 (file)
@@ -3,6 +3,7 @@ Bug #66388 (Crash on POST with Content-Length:0 and untouched body)
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 44ff3d1b92e4ab0f13dc520b3865d18df223bc84..89d4d658b8a58ee2d5cfcf94cf72ca4b8c319bbe 100644 (file)
@@ -3,6 +3,7 @@ client observer
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index b09c299764ed21be9210fd61a5c31d526d4a1857..62d0bca64be7eee3e5522918605ecdac601797ca 100644 (file)
@@ -3,6 +3,7 @@ client once & wait
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 22ad9feb221d54b0db4016bd0aafebaffe07c641..1342efaadd61601e07e08675015b532032f94b06 100644 (file)
@@ -3,6 +3,7 @@ client reset
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 36a3f0a4e73a125641d98d7730f0327deb5e2981..4576f16d0868785d328dd3cb8fac30dd8ca6557d 100644 (file)
@@ -3,6 +3,7 @@ client response callback
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 762e044b5f213864f1ec60cf6d3f0e90d471f988..7b3986e583a2703f38a6153099d4091aab9cd5f0 100644 (file)
@@ -3,6 +3,7 @@ client response callback + dequeue
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 8421b51e7678dc7c66e637e2a7c6de7f63cc9992..74cdbcd9d06f677797338ab422a324bbd1679510 100644 (file)
@@ -3,6 +3,7 @@ client response callback + requeue
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index d7fe35822517fed372a1a254fdcfcbd79389db91..31584d30c548e36372ef2695ec01c9607a90f6a8 100644 (file)
@@ -3,6 +3,7 @@ client features
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index 937045d061e2246f69d27b0f8dc791791e262ce6..e1553d65449240ec83a1d70875b4023c4881af5c 100644 (file)
@@ -3,6 +3,7 @@ client static cookies
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
@@ -32,16 +33,4 @@ foreach (http\Client::getAvailableDrivers() as $driver) {
 Done
 --EXPECTREGEX--
 Test
-(?:string\(46\) "Array
-\(
-    \[test\] \=\> bar
-    \[foo\] \=\> test
-\)
-"
-string\(46\) "Array
-\(
-    \[test\] \=\> test
-    \[foo\] \=\> bar
-\)
-"
-)+Done
+(?:string\(46\) "Array\n\(\n    \[test\] \=\> bar\n    \[foo\] \=\> test\n\)\n"\nstring\(46\) "Array\n\(\n    \[test\] \=\> test\n    \[foo\] \=\> bar\n\)\n"\n)+Done
index 188b1782afd73dde8f2ef6630e9c13a7a56b0329..17c60ed61ec869b6b4bf8544e0e78f6e04c24b1a 100644 (file)
@@ -3,6 +3,7 @@ client history
 --SKIPIF--
 <?php 
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php 
@@ -40,12 +41,12 @@ X-Original-Content-Length: 6
 
 foobar
 HTTP/1.1 200 OK
+Vary: %s
+Content-Type: text/html
 Date: %s
 Server: %s
-Vary: %s
+X-Original-Transfer-Encoding: chunked
 Content-Length: 19
-Content-Type: text/html
-X-Original-Content-Length: 19
 
 string(6) "foobar"
 
@@ -59,12 +60,12 @@ X-Original-Content-Length: 6
 
 foobar
 HTTP/1.1 200 OK
+Vary: %s
+Content-Type: text/html
 Date: %s
 Server: %s
-Vary: %s
+X-Original-Transfer-Encoding: chunked
 Content-Length: 19
-Content-Type: text/html
-X-Original-Content-Length: 19
 
 string(6) "foobar"
 
@@ -78,12 +79,12 @@ X-Original-Content-Length: 6
 
 foobar
 HTTP/1.1 200 OK
+Vary: %s
+Content-Type: text/html
 Date: %s
 Server: %s
-Vary: %s
+X-Original-Transfer-Encoding: chunked
 Content-Length: 19
-Content-Type: text/html
-X-Original-Content-Length: 19
 
 string(6) "foobar"
 
index 71e5081a5f938220b3f7639ef9bd08702b756125..ad6c2eb15f0d477cddc9e7712b6dd18999233176 100644 (file)
@@ -3,6 +3,7 @@ client ssl
 --SKIPIF--
 <?php 
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php 
index 0de05476db8cff1b2b0fe90f349f1189845053e1..00bae4e0de5c7f7419b42c46c1240d5a1d33d9e4 100644 (file)
@@ -3,6 +3,7 @@ client observers
 --SKIPIF--
 <?php 
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php 
@@ -50,7 +51,7 @@ $client->attach(
                )
 );
 
-$client->enqueue(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/"))->send();
+$client->enqueue(new http\Client\Request("GET", "http://www.example.com/"))->send();
 var_dump(1 === preg_match("/(\.-)+/", $client->pi));
 var_dump(3 === count($client->getObservers()));
 $client->detach($o1);
index 2f2529123950a8ef2fbb4c196e03faf834a8d919..270512b358ab926c94fd2edda42d17390aa6048a 100644 (file)
@@ -3,6 +3,7 @@ client response cookie
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
@@ -20,26 +21,4 @@ foreach (http\Client::getAvailableDrivers() as $driver) {
 Done
 --EXPECTREGEX--
 Test
-(?:array\(7\) \{
-  \["cookies"\]\=\>
-  array\(2\) \{
-    \["foo"\]\=\>
-    string\(3\) "bar"
-    \["bar"\]\=\>
-    string\(3\) "foo"
-  \}
-  \["extras"\]\=\>
-  array\(0\) \{
-  \}
-  \["flags"\]\=\>
-  int\(0\)
-  \["expires"\]\=\>
-  int\(\-1\)
-  \["max\-age"\]\=\>
-  int\(\-1\)
-  \["path"\]\=\>
-  string\(0\) ""
-  \["domain"\]\=\>
-  string\(0\) ""
-\}
-)+Done
+(?:array\(7\) \{\n  \["cookies"\]\=\>\n  array\(2\) \{\n    \["foo"\]\=\>\n    string\(3\) "bar"\n    \["bar"\]\=\>\n    string\(3\) "foo"\n  \}\n  \["extras"\]\=\>\n  array\(0\) \{\n  \}\n  \["flags"\]\=\>\n  int\(0\)\n  \["expires"\]\=\>\n  int\(\-1\)\n  \["max\-age"\]\=\>\n  int\(\-1\)\n  \["path"\]\=\>\n  string\(0\) ""\n  \["domain"\]\=\>\n  string\(0\) ""\n\}\n)+Done
index 3a0c50a2c281d1e1c71a817cbdbafa56635a89a0..2379cc7e6ddf3e7717e373a1b365b9253dc79630 100644 (file)
@@ -3,6 +3,7 @@ client response cookies
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
@@ -20,44 +21,4 @@ foreach (http\Client::getAvailableDrivers() as $driver) {
 Done
 --EXPECTREGEX--
 Test
-(?:array\(7\) \{
-  \["cookies"\]\=\>
-  array\(1\) \{
-    \["temp"\]\=\>
-    string\(1[23]\) "\d+\.\d+"
-  \}
-  \["extras"\]\=\>
-  array\(0\) \{
-  \}
-  \["flags"\]\=\>
-  int\(0\)
-  \["expires"\]\=\>
-  int\(\-1\)
-  \["max\-age"\]\=\>
-  int\(\-1\)
-  \["path"\]\=\>
-  string\(0\) ""
-  \["domain"\]\=\>
-  string\(0\) ""
-\}
-array\(7\) \{
-  \["cookies"\]\=\>
-  array\(1\) \{
-    \["perm"\]\=\>
-    string\(1[23]\) "\d+\.\d+"
-  \}
-  \["extras"\]\=\>
-  array\(0\) \{
-  \}
-  \["flags"\]\=\>
-  int\(0\)
-  \["expires"\]\=\>
-  int\(\d+\)
-  \["max\-age"\]\=\>
-  int\(\-1\)
-  \["path"\]\=\>
-  string\(0\) ""
-  \["domain"\]\=\>
-  string\(0\) ""
-\}
-)+Done
+(?:array\(7\) \{\n  \["cookies"\]\=\>\n  array\(1\) \{\n    \["temp"\]\=\>\n    string\(1\d\) "\d+\.\d+"\n  \}\n  \["extras"\]\=\>\n  array\(0\) \{\n  \}\n  \["flags"\]\=\>\n  int\(0\)\n  \["expires"\]\=\>\n  int\(\-1\)\n  \["max\-age"\]\=\>\n  int\(\-1\)\n  \["path"\]\=\>\n  string\(0\) ""\n  \["domain"\]\=\>\n  string\(0\) ""\n\}\narray\(7\) \{\n  \["cookies"\]\=\>\n  array\(1\) \{\n    \["perm"\]\=\>\n    string\(1\d\) "\d+\.\d+"\n  \}\n  \["extras"\]\=\>\n  array\(0\) \{\n  \}\n  \["flags"\]\=\>\n  int\(0\)\n  \["expires"\]\=\>\n  int\(\d+\)\n  \["max\-age"\]\=\>\n  int\(\-1\)\n  \["path"\]\=\>\n  string\(0\) ""\n  \["domain"\]\=\>\n  string\(0\) ""\n\}\n)+Done
index 20dcef2270a75ba1aa155209bdd3c853fe6cb1a8..8ab936d059b94b94b4302fe77faeada7c90676f4 100644 (file)
@@ -3,6 +3,7 @@ client response transfer info
 --SKIPIF--
 <?php
 include "skipif.inc";
+skip_online_test();
 ?>
 --FILE--
 <?php
index f84c8606aeea76d18921a9fb233db9c99df4584d..deee3f2081b8d397fafb4a6a77259d46fb276862 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-env reponse callback
+env response callback
 --SKIPIF--
 <?php
 include "skipif.inc";
index 0f10264ce5bfe555a9b2d656468159ccda3563a1..28d9a1325ffb9c50a6f8746e611f4eaa12a359b4 100644 (file)
@@ -1,3 +1,15 @@
 <?php
 function _ext($ext) { extension_loaded($ext) or die("skip $ext extension needed\n"); }
 _ext("http");
+
+function skip_online_test($message = "skip test requiring internet connection\n") {
+       if (getenv("SKIP_ONLINE_TESTS")) {
+               die($message);
+       }
+}
+
+function skip_slow_test($message = "skip slow test") {
+       if (getenv("SKIP_SLOW_TESTS")) {
+               die($message);
+       }
+}