From: Michael Wallner Date: Thu, 17 Apr 2014 10:25:57 +0000 (+0200) Subject: Merge branch 'R_2_0' X-Git-Tag: RELEASE_2_1_0_RC1~39 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=af622b3219e8037dce34a4e24719cc6408ecad00;hp=592daae2e94814c46f2d961c630a36483072e9e2;p=m6w6%2Fext-http Merge branch 'R_2_0' --- diff --git a/php_http_client.c b/php_http_client.c index b2bd7f8..489177b 100644 --- a/php_http_client.c +++ b/php_http_client.c @@ -390,7 +390,7 @@ static STATUS handle_response(void *arg, php_http_client_t *client, php_http_cli zval *info, *zresponse, *zrequest; HashTable *info_ht; - if (i_zend_is_true(zend_read_property(php_http_client_class_entry, &zclient, ZEND_STRL("recordHistory"), 0 TSRMLS_CC))) { + if (z_is_true(zend_read_property(php_http_client_class_entry, &zclient, ZEND_STRL("recordHistory"), 0 TSRMLS_CC))) { handle_history(&zclient, *request, *response TSRMLS_CC); } @@ -720,7 +720,9 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_count, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(HttpClient, count) { - if (SUCCESS == zend_parse_parameters_none()) { + long count_mode = -1; + + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) { php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); RETVAL_LONG(zend_llist_count(&obj->client->requests)); diff --git a/php_http_client_curl.c b/php_http_client_curl.c index c691842..418a4c6 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -258,6 +258,8 @@ static int php_http_curle_raw_callback(CURL *ch, curl_infotype type, char *data, h->progress.info = "blacklist check"; } else if (php_memnstr(data, ZEND_STRL("SSL"), data + length)) { h->progress.info = "ssl negotiation"; + } else if (php_memnstr(data, ZEND_STRL("upload"), data + length)) { + h->progress.info = "uploaded"; } else if (php_memnstr(data, ZEND_STRL("left intact"), data + length)) { h->progress.info = "not disconnected"; } else if (php_memnstr(data, ZEND_STRL("closed"), data + length)) { @@ -269,6 +271,7 @@ static int php_http_curle_raw_callback(CURL *ch, curl_infotype type, char *data, } else { #if PHP_DEBUG h->progress.info = data; + data[length - 1] = '\0'; #endif } if (h->client->callback.progress.func) { diff --git a/php_http_env_request.c b/php_http_env_request.c index f2b8bf2..6aff0c0 100644 --- a/php_http_env_request.c +++ b/php_http_env_request.c @@ -96,7 +96,11 @@ static int grab_files(void *zpp TSRMLS_DC, int argc, va_list argv, zend_hash_key add_assoc_zval_ex(cpy, ZEND_STRS("file"), *tmp); zend_hash_del_key_or_index(Z_ARRVAL_P(cpy), ZEND_STRS("tmp_name"), 0, HASH_DEL_KEY); } - zend_hash_quick_update(Z_ARRVAL_P(zfiles), key->arKey, key->nKeyLength, key->h, (void *) &cpy, sizeof(zval *), NULL); + if (key->nKeyLength > 0) { + zend_hash_quick_update(Z_ARRVAL_P(zfiles), key->arKey, key->nKeyLength, key->h, (void *) &cpy, sizeof(zval *), NULL); + } else { + zend_hash_index_update(Z_ARRVAL_P(zfiles), key->h, (void *) &cpy, sizeof(zval *), NULL); + } } } diff --git a/php_http_message.c b/php_http_message.c index 61a1f74..a6414e4 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -1808,7 +1808,9 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_count, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(HttpMessage, count) { - if (SUCCESS == zend_parse_parameters_none()) { + long count_mode = -1; + + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) { long i = 0; php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); diff --git a/php_http_misc.h b/php_http_misc.h index 75090bd..fe08d6d 100644 --- a/php_http_misc.h +++ b/php_http_misc.h @@ -127,6 +127,12 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i # define PHP_HTTP_ZEND_LITERAL_CCN , NULL #endif +#if PHP_VERSION_ID < 50700 +# define z_is_true zend_is_true +#else +# define z_is_true(z) zend_is_true(z TSRMLS_CC) +#endif + #define INIT_PZVAL_ARRAY(zv, ht) \ { \ INIT_PZVAL((zv)); \ diff --git a/tests/client010.phpt b/tests/client010.phpt index 7563a77..803403f 100644 --- a/tests/client010.phpt +++ b/tests/client010.phpt @@ -8,29 +8,32 @@ include "skipif.inc"; getBody()->addForm(null, array("file"=>__FILE__, "name"=>"upload", "type"=>"text/plain")); - -foreach (http\Client::getAvailableDrivers() as $driver) { - $client = new http\Client($driver); - $client->enqueue($request)->send(); - var_dump($client->getResponse()->getBody()->toString()); -} -?> -Done ---EXPECTREGEX-- -Test -(?:string\(\d+\) "Array +$RE = +'/(Array \( \[upload\] \=\> Array \( \[name\] \=\> client010\.php \[type\] \=\> text\/plain - \[tmp_name\] \=\> .* + \[tmp_name\] \=\> .+ \[error\] \=\> 0 \[size\] \=\> \d+ \) \) -" -)+Done +)+/'; +$request = new http\Client\Request("POST", "http://dev.iworks.at/ext-http/.print_request.php"); +$request->getBody()->addForm(null, array("file"=>__FILE__, "name"=>"upload", "type"=>"text/plain")); + +foreach (http\Client::getAvailableDrivers() as $driver) { + $client = new http\Client($driver); + $client->enqueue($request)->send(); + if (!preg_match($RE, $s = $client->getResponse()->getBody()->toString())) { + echo($s); + } +} +?> +Done +--EXPECT-- +Test +Done \ No newline at end of file diff --git a/tests/envresponse003.phpt b/tests/envresponse003.phpt index 3bbf760..7a02814 100644 --- a/tests/envresponse003.phpt +++ b/tests/envresponse003.phpt @@ -18,7 +18,7 @@ $r->setBody(new http\Message\Body(fopen(__FILE__, "rb"))); $r->send(); ?> ---EXPECTHEADERS-- -Content-Type: text/plain +--EXPECTHEADERSF-- +Content-Type: text/plain%s --EXPECTF-- php diff --git a/tests/envresponseheader001.phpt b/tests/envresponseheader001.phpt index 194f7d7..3997cf8 100644 --- a/tests/envresponseheader001.phpt +++ b/tests/envresponseheader001.phpt @@ -34,6 +34,6 @@ Array [2] => good ) - [Content-Type] => text/html + [Content-Type] => %s ) Created diff --git a/tests/etag001.phpt b/tests/etag001.phpt index b3a2a53..c1e1e44 100644 --- a/tests/etag001.phpt +++ b/tests/etag001.phpt @@ -11,7 +11,12 @@ version_compare(PHP_VERSION, "5.4.0", ">=") or die("skip PHP>=5.4 required"); $body = new http\Message\Body; $body->append("Hello, my old fellow."); foreach (hash_algos() as $algo) { - if ($algo == "gost-crypto") continue; + switch ($algo) { + case "gost-crypto": + case "fnv1a32": + case "fnv1a64": + continue 2; + } ini_set("http.etag.mode", $algo); printf("%10s: %s\n", $algo,