ID: 15279 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Feedback Bug Type: Documentation problem Operating System: Linux PHP Version: 4.1.1 Assigned To: torben New Comment:
Scratch the first paragraph of my last post. :) Torben Previous Comments: ------------------------------------------------------------------------ [2002-02-08 17:01:43] [EMAIL PROTECTED] Well, in the first place, the results below show that it did in fact work for you, but that your server isn't set up to provide a directory listing of the root dir and also doesn't have an index file there. A bit more research shows that valid values for CURLOPT_CUSTOMREQUEST are things like 'GET', 'HEAD', 'DELETE', and so on. You should not enter the whole request line, and you should not enter any newlines/carriage returns. If the following script works for you, I will reclassify this as a documentation problem. <?php error_reporting(E_ALL); $c = curl_init(); $request = "GET"; curl_setopt($c, CURLOPT_URL, 'http://localhost:8080/testfiles/phptest.php'); curl_setopt($c, CURLOPT_CUSTOMREQUEST, $request); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); echo trim(curl_exec($c)); curl_close($c); ?> Torben ------------------------------------------------------------------------ [2002-02-08 16:42:03] [EMAIL PROTECTED] Sure. Here are some very simple runs and results. I do not think that any request will ever work. ----- START ----- SRC <? $curl = curl_init(); $request = 'GET' . "\r\n"; curl_setopt($curl, CURLOPT_URL, 'http://localhost:8080/'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request); $data = curl_exec ($curl); echo $data . "\r\n"; ?> ----- RESULT [BLANK] ----- END ----- START ----- SRC <? $curl = curl_init(); $request = 'GET' . "\r\n"; curl_setopt($curl, CURLOPT_URL, 'http://localhost:8080/'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($curl); echo $data . "\r\n"; ?> ----- RESULT <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>403 Forbidden</TITLE> </HEAD><BODY> <H1>Forbidden</H1> You don't have permission to access / on this server.<P> <HR> <ADDRESS>Apache/1.3.22 Server at 127.0.0.1 Port 8080</ADDRESS> </BODY></HTML> ----- END ----- START ----- SRC <? $curl = curl_init(); $request = 'GET' . "\r\n"; curl_setopt($curl, CURLOPT_URL, 'http://localhost:8080/'); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request); $data = curl_exec ($curl); ?> ----- RESULT <HTML><HEAD> <TITLE>403 Forbidden</TITLE> </HEAD><BODY> <H1>Forbidden</H1> You don't have permission to access / on this server.<P> <HR> <ADDRESS>Apache/1.3.22 Server at 127.0.0.1 Port 8080</ADDRESS> </BODY></HTML> ----- END ------------------------------------------------------------------------ [2002-02-08 16:26:29] [EMAIL PROTECTED] What happens if you try with a valid HTTP request, or just 'GET', as the custom response? The script you gave below didn't work for me either, but did if I did either of: $request = "GET /index.html HTTP/1.0\r\n\r\n"; ...or... $request = "GET"; Can you try that and report back? Torben ------------------------------------------------------------------------ [2002-01-29 11:53:52] [EMAIL PROTECTED] When using curl to request a page, if I just set RETURNTRANSFER curlopt, things work as expected (output is dumped into a variable). If I just set CUSTOMREQUEST, thinks work as expected (output is dumped to stdout). However, if I set RETURNTRANSFER and CUSTOMREQUEST at the same time, I get no output. The request is made, according to my apache logs, but I get nothing. Here is some demo code: <? $c = curl_init(); $request = ''; $request .= 'GET /testfiles/phptest.php' . "\r\n"; curl_setopt($c, CURLOPT_URL, 'http://localhost:8080/testfiles/phptest.php'); curl_setopt($c, CURLOPT_CUSTOMREQUEST, $request); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); echo trim( curl_exec($c) ); curl_close($c); ?> That is an example of a request that will not work. Comment either one of the "curl_setopt" lines out and it will. Thanks, robert ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15279&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php