SA-MP Forums Archive
HTTP Error - 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: HTTP Error (/showthread.php?tid=402296)



HTTP Error - Deduction - 26.12.2012

Hello, I recently have been looking at the HTTP function in SA:MP and noticed that it wouldnt work.

I tried the example from the wiki:

pawn Code:
forward MyHttpResponse(index, response_code, data[]);
 
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/hello",cmdtext,true))
    {
        HTTP(playerid, HTTP_GET, "myqontrol.com/motd.ini", "", "MyHttpResponse");
        return 1;
    }
    return 0;
}
 
public MyHttpResponse(index, response_code, data[])
{
    // In this callback "index" would normally be called "playerid" ( if you didn't get it already :) )
    new
        buffer[ 128 ];
    if(response_code == 200) //Did the request succeed?
    {
        //Yes!
        format(buffer, sizeof(buffer), "The URL replied: %s", data);
        SendClientMessage(index, 0xFFFFFFFF, buffer);
    }
    else
    {
        //No!
        format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code);
        SendClientMessage(index, 0xFFFFFFFF, buffer);
    }
}
Replaced the URL with myqontrol.com/motd.ini which shows the numbers 12345.

But when I type in the command /hello it says the Request Failed and the response code was 6.
6 is HTTP_ERROR_MALFORMED_RESPONSE

What has happened and how can I fix that?


Re: HTTP Error - Deduction - 26.12.2012

It seems to be okay. I dont understand how its not working lol.