HTTP Error
#1

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?
Reply
#2

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


Forum Jump:


Users browsing this thread: 1 Guest(s)