|
| 1 | +--TEST-- |
| 2 | +Basic curl_share test |
| 3 | +--EXTENSIONS-- |
| 4 | +curl |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | +include 'skipif-nocaddy.inc'; |
| 8 | + |
| 9 | +function get_persistent_share_handle(): CurlShareHandle { |
| 10 | + return curl_share_init( |
| 11 | + [ |
| 12 | + CURL_LOCK_DATA_CONNECT, |
| 13 | + ], |
| 14 | + "persistent-test", |
| 15 | + ); |
| 16 | +} |
| 17 | + |
| 18 | +$sh1 = get_persistent_share_handle(); |
| 19 | +$ch1 = curl_init("https://localhost"); |
| 20 | + |
| 21 | +curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); |
| 22 | +curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); |
| 23 | +curl_setopt($ch1, CURLOPT_SHARE, $sh1); |
| 24 | + |
| 25 | +$sh2 = get_persistent_share_handle(); |
| 26 | +$ch2 = curl_init("https://localhost"); |
| 27 | + |
| 28 | +curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false); |
| 29 | +curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); |
| 30 | +curl_setopt($ch2, CURLOPT_SHARE, $sh2); |
| 31 | + |
| 32 | +var_dump(curl_exec($ch1)); |
| 33 | +var_dump(curl_exec($ch2)); |
| 34 | + |
| 35 | +var_dump("second connect_time: " . (curl_getinfo($ch2)["connect_time"])); |
| 36 | + |
| 37 | +?> |
| 38 | +--EXPECT-- |
| 39 | +string(23) "Caddy is up and running" |
| 40 | +string(23) "Caddy is up and running" |
| 41 | +string(22) "second connect_time: 0" |
0 commit comments