|
| 1 | +--TEST-- |
| 2 | +Bug #76675 (Segfault with H2 server push write/writeheader handlers) |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +include 'skipif.inc'; |
| 6 | +if (getenv("SKIP_ONLINE_TESTS")) { |
| 7 | + die("skip online test"); |
| 8 | +} |
| 9 | +$curl_version = curl_version(); |
| 10 | +if ($curl_version['version_number'] < 0x073d00) { |
| 11 | + exit("skip: test may crash with curl < 7.61.0"); |
| 12 | +} |
| 13 | +?> |
| 14 | +--FILE-- |
| 15 | +<?php |
| 16 | +$transfers = 1; |
| 17 | +$callback = function($parent, $passed) use (&$transfers) { |
| 18 | + curl_setopt($passed, CURLOPT_WRITEFUNCTION, function ($ch, $data) { |
| 19 | + echo "Received ".strlen($data); |
| 20 | + return strlen($data); |
| 21 | + }); |
| 22 | + $transfers++; |
| 23 | + return CURL_PUSH_OK; |
| 24 | +}; |
| 25 | +$mh = curl_multi_init(); |
| 26 | +curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); |
| 27 | +curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback); |
| 28 | +$ch = curl_init(); |
| 29 | +curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush'); |
| 30 | +curl_setopt($ch, CURLOPT_HTTP_VERSION, 3); |
| 31 | +curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
| 32 | +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
| 33 | +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 34 | +curl_multi_add_handle($mh, $ch); |
| 35 | +$active = null; |
| 36 | +do { |
| 37 | + $status = curl_multi_exec($mh, $active); |
| 38 | + do { |
| 39 | + $info = curl_multi_info_read($mh); |
| 40 | + if (false !== $info && $info['msg'] == CURLMSG_DONE) { |
| 41 | + $handle = $info['handle']; |
| 42 | + if ($handle !== null) { |
| 43 | + $transfers--; |
| 44 | + curl_multi_remove_handle($mh, $handle); |
| 45 | + curl_close($handle); |
| 46 | + } |
| 47 | + } |
| 48 | + } while ($info); |
| 49 | +} while ($transfers); |
| 50 | +curl_multi_close($mh); |
| 51 | +?> |
| 52 | +--EXPECTREGEX-- |
| 53 | +(Received \d+)+ |
0 commit comments