ID: 15279 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Linux PHP Version: 4.1.1 Assigned To: torben New Comment:
Cool--I've already updated the manual to mention that this is the way that option should be used, so I'm gonna close this bug now. And yeah, I've not looked into why it will sometimes work with the whole request shoved in there, but it sometimes does and sometimes doesn't, so there you go. Thanks for the report, Torben Previous Comments: ------------------------------------------------------------------------ [2002-02-08 20:54:50] [EMAIL PROTECTED] Yes, actually, that is what I would have expected it to return, since my machine doesn't have any index file in the root director. Only, I would have expected it in all three cases, but I guess you caught that :) Anyhow, it appears you are right, and that I am misusing the CUSTOMREQUEST option. Your example executed as expected. I looked at the curl_easy_setopt manpage and confirmed this (why I had not caught this before from the man page is a good question). The strange thing is that I have been using CUSTOMREQUEST on a machine running 4.0.6 to post XML in a fashion such as this: $xml = ''; $xml .= "POST /somepath HTTP/1.1\r\n"; $xml .= "Host: somehost\r\n"; $xml .= "Content-Type: text/xml\r\n"; $xml .= "\r\n" $xml .= $xmldoc; ... curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request); ... Anyhow, I feel really silly now; I should have seen this answer long before now. But at least I know why I haven't been able to duplicate the behavior of the one machine that is working, though why it is working is an interesting question. Thanks, robert ------------------------------------------------------------------------ [2002-02-08 17:08:05] [EMAIL PROTECTED] Scratch the first paragraph of my last post. :) Torben ------------------------------------------------------------------------ [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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/15279 -- 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