Download src/php/php-src/ext/curl/tests/curl_CURLOPT_READDATA.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/curl/tests/curl_CURLOPT_READDATA.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/curl/tests/curl_CURLOPT_READDATA.phpt
-
curl -L -o curl_CURLOPT_READDATA.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/curl/tests/curl_CURLOPT_READDATA.phpt
1.06 kB
| --TEST-- | |
| Test CURLOPT_READDATA without a callback function | |
| --CREDITS-- | |
| Mattijs Hoitink mattijshoitink@gmail.com | |
| #Testfest Utrecht 2009 | |
| --EXTENSIONS-- | |
| curl | |
| --FILE-- | |
| include 'server.inc'; | |
| $host = curl_cli_server_start(); | |
| // The URL to POST to | |
| $url = $host . '/get.inc?test=post'; | |
| // Create a temporary file to read the data from | |
| $tempname = tempnam(sys_get_temp_dir(), 'CURL_DATA'); | |
| $datalen = file_put_contents($tempname, "hello=world&smurf=blue"); | |
| ob_start(); | |
| $ch = curl_init($url); | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_READDATA, fopen($tempname, 'rb')); | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:', "Content-Length: {$datalen}")); | |
| if (false === $response = curl_exec($ch)) { | |
| echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch); | |
| } else { | |
| echo $response; | |
| } | |
| curl_close($ch); | |
| // Clean the temporary file | |
| @unlink($tempname); | |
| --EXPECT-- | |
| array(2) { | |
| ["hello"]=> | |
| string(5) "world" | |
| ["smurf"]=> | |
| string(4) "blue" | |
| } | |