Re: Can't seem to be able to do a get request
| From: | Ernest E Vogelsinger | Date: | Thu, 13 Mar 2003 14:58:06 +0000 |
| Subject: | Re: Can't seem to be able to do a get request | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139513@lists.php.net to get a copy of this message | ||
At 14:50 13.03.2003, Mathieu Dumoulin said:
--------------------[snip]--------------------
>I got this script i wish to run like it was a seperate thread on the server
>cause i can't run anything with a crontab but i can't seem to do a valid GET
>request thru fsockopen. If anyone can help me please.
>
>
>$fp = fsockopen ("sandbox.lhjmq.xl5.net", 80);
>if ($fp) {
>
>fputs ($fp, "GET /lang_fr/index.php HTTP/1.1");
>while (!feof($fp)) echo fgets ($fp,128);
>fclose ($fp);
>}
>
>I run the script from the web but nothing happens. If i run it also with the
>real URL i want to get (I cannot show this url for security reasons) my
>processor and mysql process should go up to 80% each for like 40 seconds and
>my "top" command in shell would show it, but it's not happenning. Now i
>tried index.php and still nothing!
--------------------[snip]--------------------
If you perform an HTTP request indicating a version of 1.0 or higher, a bit
more info is required for the server to process the request. Your simple
GET statement would probably work if you indicate HTTP/0.9, but it is
questionable if the receiving server would direct the request to the
correct domain (would only be if this was the "default domain" for the IP
address).
For a complete reference on the HTTP protocol look at RFC2616
ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt
In short for your request to work you should at least transmit these lines:
GET /lang_fr/ index.php HTTP/1.1 [CRLF]
Host: www.myhost.com [CRLF]
Accept: */* [CRLF][CRLF]
where [CR] is a _complete_ CarriageReturn/LineFeed sequence "\r\n". Of
course you may add more headers to it.
You might also want to check out cURL for threaded requests.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/