Why doesn't HTTP work for local servers? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why doesn't HTTP work for local servers? (
/showthread.php?tid=359172)
Why doesn't HTTP work for local servers? -
Sinner - 13.07.2012
This actually took me a while to figure out, since i coulden't find any proper HTTP documentation apart from the one on the sa-mp wiki. Why does HTTP not work when u try to send requests to a local server?
Example, this will not work and will always return status code 6:
pawn Код:
#define SERVER "127.0.0.1/index.php" // let's assume index.php exists and returns "OK"
HTTP(playerid, HTTP_GET, SERVER, "", "HTTPResponse");
// Will return status code 6
// Data: nothing
whereas this will work just fine (stuntplanet.ugngames.net/ is a live server)
pawn Код:
#define SERVER "www.stuntplanet.ugngames.net/index.php" // let's assume index.php exists and returns "OK"
HTTP(playerid, HTTP_GET, SERVER, "", "HTTPResponse");
// Will return status code 200
// Data: "OK"
index.php
It just seems strange to me?
Re: Why doesn't HTTP work for local servers? -
Vince - 13.07.2012
I've had some weird issues with this myself where HTTP would return status code 6, but the request did actually succeed. Status code 6 isn't even a valid HTTP response so I am clueless as to what it means.
By the way, your php code is syntactically incorrect, so different versions of php might interpret it differently. Try this:
PHP код:
<?php echo "OK" ?>
Re: Why doesn't HTTP work for local servers? -
Sinner - 13.07.2012
Quote:
Originally Posted by Vince
I've had some weird issues with this myself where HTTP would return status code 6, but the request did actually succeed. Status code 6 isn't even a valid HTTP response so I am clueless as to what it means.
By the way, your php code is syntactically incorrect, so different versions of php might interpret it differently. Try this:
PHP код:
<?php echo "OK" ?>
|
<?="string"?> is a shorter way of writing <?php echo "string" ?>, works fine
The sa-mp wiki says status code 6 = HTTP_ERROR_MALFORMED_RESPONSE but I have no clue why.