Download src/php/php-src/ext/curl/tests/bug77535.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/curl/tests/bug77535.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/curl/tests/bug77535.phpt
-
curl -L -o bug77535.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/curl/tests/bug77535.phpt
2.36 kB
| --TEST-- | |
| Bug #77535 (Invalid callback, h2 server push) | |
| --EXTENSIONS-- | |
| curl | |
| --XFAIL-- | |
| --SKIPIF-- | |
| include 'skipif-nocaddy.inc'; | |
| $curl_version = curl_version(); | |
| if ($curl_version['version_number'] < 0x080100) { | |
| exit("skip: test may crash with curl < 8.1.0"); | |
| } | |
| --FILE-- | |
| 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://localhost/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; | |
| } | |
| echo "Start handle request.\n"; | |
| return; | |
| } | |
| } | |
| } | |
| 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. | |