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;
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);
}
client->callback.progress.func(client->callback.progress.arg, client, e, progress);
}
+ if (dequeue) {
+ php_http_client_dequeue(client, e->request);
+ }
+
return SUCCESS;
}
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);
}
}
#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)
}
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);
}
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
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
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
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"
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"
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"
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
)
);
-$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);
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
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
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
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
--SKIPIF--
<?php
include "skipif.inc";
+skip_online_test();
?>
--FILE--
<?php
--TEST--
-env reponse callback
+env response callback
--SKIPIF--
<?php
include "skipif.inc";
<?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);
+ }
+}