com php-src: Added test for #77535 fix: ext/curl/tests/bug77535.phpt

From: Date: Fri, 15 Mar 2019 18:11:51 +0000
Subject: com php-src: Added test for #77535 fix: ext/curl/tests/bug77535.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105158@lists.php.net to get a copy of this message
Commit: f167b06d4c86c96291c21c027ba3cae22f5b5be8 Author: Pedro Magalhães <pmmaga@php.net> Fri, 15 Mar 2019 18:11:51 +0000 Parents: 97f9fd6949a52d1eb30c3e1c90f0789b57c29468 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f167b06d4c86c96291c21c027ba3cae22f5b5be8 Log: Added test for #77535 fix Bugs: https://bugs.php.net/77535 Changed paths: A ext/curl/tests/bug77535.phpt Diff: diff --git a/ext/curl/tests/bug77535.phpt b/ext/curl/tests/bug77535.phpt new file mode 100644 index 0000000..b79cdb9 --- /dev/null +++ b/ext/curl/tests/bug77535.phpt @@ -0,0 +1,77 @@ +--TEST-- +Bug #77535 (Invalid callback, h2 server push) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (getenv("SKIP_ONLINE_TESTS")) { + die("skip online test"); +} +$curl_version = curl_version(); +if ($curl_version['version_number'] < 0x073d00) { + exit("skip: test may crash with curl < 7.61.0"); +} +?> +--FILE-- +<?php +class MyHttpClient +{ + private $mh; + private $curl; + + public function sendRequest() + { + if (false === $this->mh = curl_multi_init()) { + throw new \RuntimeException('Unable to create a new cURL multi handle'); + } + + $this->addServerPushCallback(); + + $this->curl = curl_init(); + curl_setopt($this->curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + curl_setopt($this->curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + curl_setopt($this->curl, CURLOPT_HEADER, false); + curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false); + curl_setopt($this->curl, CURLOPT_FAILONERROR, false); + curl_setopt($this->curl, CURLOPT_URL, 'https://http2.golang.org/serverpush'); + curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); + curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($ch, $data) { + return \strlen($data); + }); + curl_setopt($this->curl, CURLOPT_WRITEFUNCTION, function ($ch, $data) { + return \strlen($data); + }); + curl_multi_add_handle($this->mh, $this->curl); + + $stillRunning = null; + while (true) { + do { + $mrc = curl_multi_exec($this->mh, $stillRunning); + } while (CURLM_CALL_MULTI_PERFORM === $mrc); + + $info = curl_multi_info_read($this->mh); + while (false !== $info && $info['msg'] == CURLMSG_DONE) { + if (CURLMSG_DONE !== $info['msg']) { + continue; + } + die("Start handle request."); + } + } + } + + private function addServerPushCallback(): void + { + + $callback = static function () { + return CURL_PUSH_OK; + }; + + curl_multi_setopt($this->mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); + curl_multi_setopt($this->mh, CURLMOPT_PUSHFUNCTION, $callback); + } +} + +$buzz = new MyHttpClient(); +$buzz->sendRequest(); +--EXPECT-- +Start handle request. +

« previous php.cvs (#105158) next »