add more cookie tests
authorMichael Wallner <mike@php.net>
Fri, 12 Jul 2019 12:25:19 +0000 (14:25 +0200)
committerMichael Wallner <mike@php.net>
Fri, 12 Jul 2019 12:25:19 +0000 (14:25 +0200)
BUGS
src/php_http_client_curl.c
tests/client031.phpt [new file with mode: 0644]
tests/client032.phpt [new file with mode: 0644]

diff --git a/BUGS b/BUGS
index 4c2ad80b6025a49554ce2b2c54e6b02063385c26..62a1511f06fb2afdb95471601bbfadeb9b9d24f7 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1,25 +1,6 @@
 Known Issues
 ============
 
 Known Issues
 ============
 
-Windows:
-       If you keep getting "SSL connect error" when trying to issue 
-               requests, try another (newer) libeay32.dll/ssleay32.dll pair.
+## libcurl-7.64.1
 
 
-Internals:
-       Inflating raw deflated data causes a re-initialization of the inflate
-               stream where the corresponding window bits are modified to tell libz
-               to not check for zlib header bytes.  This is not preventable AFAICS.
-       LFS dependant parts of libcurl are left out because of off_t,
-               respectively off64_t confusion.
-       Persistent handles and "cookiestore" request option do interfere,
-               as libcurl saves the cookies to the file on curl_easy_destroy(),
-               cookies are not saved until the CURL handle will be recycled.
-                       Thus one would either need to
-                               * run PHP with raphf.persistent_handles.limit = 0
-                               * call raphf\persistent_handles_clean() every request
-                               * call $client->flushCookies(), which is available
-                                 since libcurl v7.17.1 and does not work with the
-                                 procedural API
-       HTTP and Proxy authentication information (username/password) can not be
-               unset with NULL prior libcurl v7.19.6 and separate options for setting
-               username and password--which work--are only available since v7.19.6.
+Superfluous output of "* Closing connection #" on STDERR.
\ No newline at end of file
index 45515fa2686316497d184982fe76d95521eca955..389464bad77f4fc77c17016892c6bd8848740f6b 100644 (file)
@@ -2075,7 +2075,9 @@ static void php_http_client_curl_handler_clear(php_http_client_curl_handler_t *h
        curl_easy_setopt(handler->handle, CURLOPT_COOKIELIST, "FLUSH");
        curl_easy_setopt(handler->handle, CURLOPT_SHARE, NULL);
        /* see gh issue #84 */
        curl_easy_setopt(handler->handle, CURLOPT_COOKIELIST, "FLUSH");
        curl_easy_setopt(handler->handle, CURLOPT_SHARE, NULL);
        /* see gh issue #84 */
-       curl_easy_setopt(handler->handle, CURLOPT_COOKIEJAR, NULL);
+       //if (php_http_curle_get_storage(handler->handle)->cookiestore) {
+               //curl_easy_setopt(handler->handle, CURLOPT_COOKIEJAR, NULL);
+       //}
 }
 
 static void php_http_client_curl_handler_dtor(php_http_client_curl_handler_t *handler)
 }
 
 static void php_http_client_curl_handler_dtor(php_http_client_curl_handler_t *handler)
diff --git a/tests/client031.phpt b/tests/client031.phpt
new file mode 100644 (file)
index 0000000..3211735
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+client cookie sharing disabled
+--SKIPIF--
+<?php
+include "skipif.inc";
+skip_client_test();
+?>
+--FILE--
+<?php
+
+include "helper/server.inc";
+include "helper/dump.inc";
+
+echo "Test\n";
+
+server("cookie.inc", function($port) {
+       $client = new http\Client(null, "cookies");
+       $client->configure(array("share_cookies" => false));
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       /* requeue the previous request */
+       $client->requeue($request);
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+});
+
+?>
+===DONE===
+--EXPECTF--
+Test
+Etag: ""
+Set-Cookie: counter=1;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=1;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=2;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=1;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=1;
+X-Original-Transfer-Encoding: chunked
+
+===DONE===
diff --git a/tests/client032.phpt b/tests/client032.phpt
new file mode 100644 (file)
index 0000000..d8dfb2b
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+client cookie sharing enabled
+--SKIPIF--
+<?php
+include "skipif.inc";
+skip_client_test();
+?>
+--FILE--
+<?php
+
+include "helper/server.inc";
+include "helper/dump.inc";
+
+echo "Test\n";
+
+server("cookie.inc", function($port) {
+       $client = new http\Client(null, "cookies");
+       $client->configure(array("share_cookies" => true));
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       /* requeue the previous request */
+       $client->requeue($request);
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+       $request = new http\Client\Request("GET", "http://localhost:$port");
+       $client->enqueue($request);
+       $client->send();
+       while (($r = $client->getResponse())) {
+               dump_headers(null, $r->getHeaders());
+       }
+});
+
+?>
+===DONE===
+--EXPECTF--
+Test
+Etag: ""
+Set-Cookie: counter=1;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=2;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=2;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=3;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=4;
+X-Original-Transfer-Encoding: chunked
+
+===DONE===