1--TEST--
2Test curl_copy_handle() with User Agent
3--CREDITS--
4Rick Buitenman <rick@meritos.nl>
5#testfest Utrecht 2009
6--SKIPIF--
7<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
8--FILE--
9<?php
10
11  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
12
13  echo '*** Testing curl copy handle with User Agent ***' . "\n";
14
15  $url = "{$host}/get.php?test=useragent";
16  $ch = curl_init();
17
18  ob_start(); // start output buffering
19  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
20  curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
21  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
22
23  $copy = curl_copy_handle($ch);
24
25  var_dump( curl_exec($ch) );
26  var_dump( curl_exec($copy) );
27
28  curl_close($ch); // can not close original handle before curl_exec($copy) since it causes char * inputs to be invalid (see also: http://curl.haxx.se/libcurl/c/curl_easy_duphandle.html)
29  curl_close($copy);
30
31?>
32===DONE===
33--EXPECTF--
34*** Testing curl copy handle with User Agent ***
35string(9) "cURL phpt"
36string(9) "cURL phpt"
37===DONE===
38