From: Michael Wallner Date: Mon, 22 Aug 2016 09:55:45 +0000 (+0200) Subject: add tests X-Git-Tag: RELEASE_2_6_0_BETA1~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e8ff1c1db343e8862ff436381a9b6ba01a60a4fa;p=m6w6%2Fext-http add tests --- diff --git a/package.xml b/package.xml index 27f2fc1..d22b029 100644 --- a/package.xml +++ b/package.xml @@ -31,18 +31,39 @@ https://mdref.m6w6.name/http mike@php.net yes - 2016-03-31 + 2016-08-22 - 2.6.0 + 2.6.0beta1 2.6.0 - stable + beta stable BSD-2-Clause = 7.23.0) options to http\Client::configure() ++ http\Client uses curl_share handles to properly share cookies and SSL/TLS sessions between requests ++ Improved configure checks for default CA bundles ++ Improved negotiation precision +* Fixed regression introduced by http\Params::PARSE_RFC5987: negotiation using the params parser would receive param keys without the trailing asterisk, stripped by http\Params::PARSE_RFC5987. +* Fix gh-issue #50: http\Client::dequeue() within http\Client::setDebug() causes segfault (Mike, Maik Wagner) +* Fix gh-issue #47: http\Url: Null pointer deref in sanitize_value() (Mike, @rc0r) +* Fix gh-issue #45: HTTP/2 response message parsing broken with libcurl >= 7.49.1 (Mike) +* Fix gh-issue #43: Joining query with empty original variable in query (Mike, Sander Backus) +* Fix gh-issue #42: fatal error when using punycode in URLs (Mike, Sebastian Thielen) +* Fix gh-issue #41: Use curl_version_info_data.features when initializing options (Mike) +* Fix gh-issue #40: determinde the SSL backend used by curl at runtime (Mike, @rcanavan) +* Fix gh-issue #39: Notice: http\Client::enqueue(): Could not set option proxy_service_name (Mike, @rcanavan) +* Fix gh-issue #38: Persistent curl handles: error code not properly reset (Mike, @afflerbach) +* Fix gh-issue #36: Unexpected cookies sent if persistent_handle_id is used (Mike, @rcanavan, @afflerbach) * Fix gh-issue #34: allow setting multiple headers with the same name (Mike, @rcanavan) +* Fix gh-issue #33: allow setting prodyhost request option to NULL (Mike, @rcanavan) * Fix gh-issue #31: add/improve configure checks for default CA bundle/path (Mike, @rcanavan) ]]> @@ -69,6 +90,10 @@ https://mdref.m6w6.name/http + + + + @@ -182,6 +207,9 @@ https://mdref.m6w6.name/http + + + @@ -247,6 +275,10 @@ https://mdref.m6w6.name/http + + + + diff --git a/tests/client029.phpt b/tests/client029.phpt new file mode 100644 index 0000000..2ed6d79 --- /dev/null +++ b/tests/client029.phpt @@ -0,0 +1,124 @@ +--TEST-- +client curl user handler +--SKIPIF-- + +--FILE-- +client = $client; + } + + function init(callable $run) { + $this->run = $run; + } + + function timer($timeout_ms) { + echo "T"; + if (isset($this->timeout)) { + $this->timeout->set($timeout_ms/1000, 0); + $this->timeout->start(); + } else { + $this->timeout = new EvTimer($timeout_ms/1000, 0, function() { + if (!call_user_func($this->run, $this->client)) { + if ($this->timeout) { + $this->timeout->stop(); + $this->timeout = null; + } + } + }); + } + } + + function socket($socket, $action) { + echo "S"; + + switch ($action) { + case self::POLL_NONE: + break; + case self::POLL_REMOVE: + if (isset($this->ios[(int) $socket])) { + echo "U"; + $this->ios[(int) $socket]->stop(); + unset($this->ios[(int) $socket]); + } + break; + + default: + $ev = 0; + if ($action & self::POLL_IN) { + $ev |= Ev::READ; + } + if ($action & self::POLL_OUT) { + $ev |= Ev::WRITE; + } + if (isset($this->ios[(int) $socket])) { + $this->ios[(int) $socket]->set($socket, $ev); + } else { + $this->ios[(int) $socket] = new EvIo($socket, $ev, function($watcher, $events) use($socket) { + $action = 0; + if ($events & Ev::READ) { + $action |= self::POLL_IN; + } + if ($events & Ev::WRITE) { + $action |= self::POLL_OUT; + } + if (!call_user_func($this->run, $this->client, $socket, $action)) { + if ($this->timeout) { + $this->timeout->stop(); + $this->timeout = null; + } + } + }); + } + break; + } + } + + function once() { + throw new BadMethodCallException("this test uses Ev::run()"); + } + + function wait($timeout_ms = null) { + throw new BadMethodCallException("this test uses Ev::run()"); + } + + function send() { + throw new BadMethodCallException("this test uses Ev::run()"); + } +} + + +include "helper/server.inc"; + +server("proxy.inc", function($port) { + $client = new http\Client; + $client->configure([ + "use_eventloop" => new UserHandler($client) + ]); + $client->enqueue(new http\Client\Request("GET", "http://localhost:$port/"), function($r) { + var_dump($r->getResponseCode()); + }); + Ev::run(); +}); + +?> +===DONE=== +--EXPECTREGEX-- +Test +T[ST]+U+int\(200\) +===DONE=== diff --git a/tests/gh-issue48.phpt b/tests/gh-issue48.phpt new file mode 100644 index 0000000..ae12825 --- /dev/null +++ b/tests/gh-issue48.phpt @@ -0,0 +1,177 @@ +--TEST-- +url errors +--SKIPIF-- + +--FILE-- +getMessage(), "\n"; + } + + echo "# IGNORE\n"; + echo new http\Url($url, null, $flags|http\Url::IGNORE_ERRORS), "\n"; + + echo "# SILENT\n"; + echo new http\Url($url, null, $flags|http\Url::SILENT_ERRORS), "\n"; + + echo "# IGNORE|SILENT\n"; + echo new http\Url($url, null, $flags|http\Url::IGNORE_ERRORS|http\Url::SILENT_ERRORS), "\n"; + echo "==========\n"; +} + +test("http://.foo.bar/?q=1"); +test("http://..foo.bar/i.x"); +test("http://foo..bar/i..x"); +test("http://-foo.bar"); +test("http://--foo.bar"); +test("http://f--oo.bar"); +test("htto://foo.bar/?q=%"); +test("htto://foo.bar/?q=%", http\Url::PARSE_TOPCT); +test("http://a\xc3\xc3b"); +test("http://[foobar]:123"); +test("#/?foo=&#", http\Url::PARSE_MBUTF8); + +?> + +===DONE=== +--EXPECTF-- +Test +# DEFAULT +http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '.foo.bar/?q=1' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '.foo.bar/?q=1' in %sgh-issue48.php on line %d +http://foo.bar/?q=1 +# SILENT + +# IGNORE|SILENT +http://foo.bar/?q=1 +========== +# DEFAULT +http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '..foo.bar/i.x' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 0 in '..foo.bar/i.x' in %sgh-issue48.php on line %d + +Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 1 in '..foo.bar/i.x' in %sgh-issue48.php on line %d +http://foo.bar/i.x +# SILENT + +# IGNORE|SILENT +http://foo.bar/i.x +========== +# DEFAULT +http\Url::__construct(): Failed to parse host; unexpected '.' at pos 4 in 'foo..bar/i..x' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse host; unexpected '.' at pos 4 in 'foo..bar/i..x' in %sgh-issue48.php on line %d +http://foo.bar/i..x +# SILENT + +# IGNORE|SILENT +http://foo.bar/i..x +========== +# DEFAULT +http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '-foo.bar' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '-foo.bar' in %sgh-issue48.php on line %d +http://foo.bar/ +# SILENT + +# IGNORE|SILENT +http://foo.bar/ +========== +# DEFAULT +http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '--foo.bar' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 0 in '--foo.bar' in %sgh-issue48.php on line %d + +Warning: http\Url::__construct(): Failed to parse host; unexpected '-' at pos 1 in '--foo.bar' in %sgh-issue48.php on line %d +http://foo.bar/ +# SILENT + +# IGNORE|SILENT +http://foo.bar/ +========== +# DEFAULT +http://f--oo.bar/ +# IGNORE +http://f--oo.bar/ +# SILENT +http://f--oo.bar/ +# IGNORE|SILENT +http://f--oo.bar/ +========== +# DEFAULT +http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' in %sgh-issue48.php on line %d +htto://foo.bar/?q=% +# SILENT + +# IGNORE|SILENT +htto://foo.bar/?q=% +========== +# DEFAULT +http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse query; invalid percent encoding at pos 2 in 'q=%' in %sgh-issue48.php on line %d +htto://foo.bar/?q=%25 +# SILENT + +# IGNORE|SILENT +htto://foo.bar/?q=%25 +========== +# DEFAULT +http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 1 in 'a%c%cb' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 1 in 'a%c%cb' in %sgh-issue48.php on line %d + +Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0xc3 at pos 2 in 'a%c%cb' in %sgh-issue48.php on line %d +http://ab/ +# SILENT + +# IGNORE|SILENT +http://ab/ +========== +# DEFAULT +http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[foobar]:123' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[foobar]:123' in %sgh-issue48.php on line %d + +Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0x5b at pos 0 in '[foobar]:123' in %sgh-issue48.php on line %d + +Warning: http\Url::__construct(): Failed to parse hostinfo; unexpected byte 0x5d at pos 7 in '[foobar]:123' in %sgh-issue48.php on line %d +http://foobar:123/ +# SILENT + +# IGNORE|SILENT +http://foobar:123/ +========== +# DEFAULT +http\Url::__construct(): Failed to parse fragment; invalid fragment identifier at pos 7 in '/?foo=&#' +# IGNORE + +Warning: http\Url::__construct(): Failed to parse fragment; invalid fragment identifier at pos 7 in '/?foo=&#' in /home/mike/src/ext-http.git/tests/gh-issue48.php on line 13 +#/?foo=&# +# SILENT + +# IGNORE|SILENT +#/?foo=&# +========== + +===DONE===