Why doesn't HTTP work for local servers?
#1

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
PHP код:
<?="OK"?>
It just seems strange to me?
Reply
#2

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" ?>
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)