Merge branch 'R_2_0'
authorMichael Wallner <mike@php.net>
Thu, 17 Apr 2014 10:25:57 +0000 (12:25 +0200)
committerMichael Wallner <mike@php.net>
Thu, 17 Apr 2014 10:25:57 +0000 (12:25 +0200)
php_http_client.c
php_http_client_curl.c
php_http_env_request.c
php_http_message.c
php_http_misc.h
tests/client010.phpt
tests/envresponse003.phpt
tests/envresponseheader001.phpt
tests/etag001.phpt

index b2bd7f8c023f4e02261b01eedff1e178e74fb2c8..489177bf7a23fbcfdd347c875859ff79ba9b2afa 100644 (file)
@@ -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));
index c6918426264ea3fa32df358a5f208c2ba14d63b5..418a4c666504ddabd2fca3b21a3638795118a3e9 100644 (file)
@@ -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) {
index f2b8bf20fe36bec862cb4d531cdece047d69f9fd..6aff0c00fe0d106fba418841e061efc02bb7778d 100644 (file)
@@ -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);
+                       }
                }
        }
 
index 61a1f747d9660781a9015112467ae54662dcec2b..a6414e400dea8182bf3324c828d4d572e26e7d9b 100644 (file)
@@ -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);
 
index 75090bdad4cc70dccffae0130e87d8f63dc8ae9c..fe08d6d1d5efd63b3b54c1adab9362d0d493a431 100644 (file)
@@ -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)); \
index 7563a7760246250be341a47de3c248e6c74e9d81..803403f4686366fb78fc83728b07f39cdcb908a6 100644 (file)
@@ -8,29 +8,32 @@ include "skipif.inc";
 <?php
 echo "Test\n";
 
-$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();
-       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
index 3bbf760c7dc77b69ce8212358504ec682f7ac77e..7a02814c27c5b5ea60ecfbeee42ba1c917ecb5da 100644 (file)
@@ -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
index 194f7d78f811928b4440eb55d94320c2835caebe..3997cf88f3fa03670c1eb5938f255988c83b1b7a 100644 (file)
@@ -34,6 +34,6 @@ Array
             [2] => good
         )
 
-    [Content-Type] => text/html
+    [Content-Type] => %s
 )
 Created
index b3a2a5347fbe4207dc2425604e578a8e88805e96..c1e1e44c897a92587198dcab8fd16bb1bf156703 100644 (file)
@@ -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,