HTTP function crashing the server
#1

Hi!

I have experienced this crash for some time now and noticed that if you use GET on a page with too much content, your server will just crash.

I really can't even limit the string sent.

pawn Код:
public OnPotatoHTTPResponse( index, response_code, data[ ] );

public OnGameModeInit( )
{
    HTTP( INVALID_PLAYER_ID, HTTP_GET, "sfcnr.com/potato", "", "OnPotatoHTTPResponse" );
    return 1;
}

public OnPotatoHTTPResponse( index, response_code, data[ ] )
{
    if( strlen( data ) < 1024 ) return 0;
    printf( "%s", data );
    return 1;
}
Specifically that link will lead you to a internal server crash.

Please fix this! Thanks.
Reply
#2

Have you tried receiving it into chunks?
Reply
#3

Check if there is any firewall issue which is blocking it. Also, there might be a limit for data, I'm unsure about it, but that could be the issue too.
Reply
#4

Quote:
Originally Posted by iZN
Посмотреть сообщение
Check if there is any firewall issue which is blocking it. Also, there might be a limit for data, I'm unsure about it, but that could be the issue too.
There isn't. I tried this on my main server and my local server. Both crash. You might want to try this too.

Quote:
Originally Posted by ProjectMan
Посмотреть сообщение
Have you tried receiving it into chunks?
How does one receive it in chunks...? Not even sure if that makes sense for this scenario.

Never the less, in chunks would be slow as hell.
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
There isn't. I tried this on my main server and my local server. Both crash. You might want to try this too.



How does one receive it in chunks...? Not even sure if that makes sense for this scenario.

Never the less, in chunks would be slow as hell.
pawn Код:
new string[1024];
    while(strlen(data) > 1024)
    {
        format(string,sizeof(string),data);
        strdel(data,0,1024);
        printf(string);
    }
    printf(data);
Something like this I'm guessing.
Reply
#6

Quote:
Originally Posted by tyler12
Посмотреть сообщение
-pawn code-

Something like this I'm guessing.
No that STILL will not work.

It crashes the server as soon as OnPotatoHTTPResponse is called.
Reply
#7

The page content is copied to the AMX heap when passed to an HTTP callback (that's true for all callbacks taking a string parameter), and if the heap is too small to hold the data you may run into problems like this. You can use #pragma dynamic to fix it but the server can tsill crash if the page suddenly becomes bigger, so it's kind of not a real fix. It would have been better if Kalcor introduced a new API for getting the content instead of merely passing it to a callback, like GetHTTPResponseData(dest[], size) or something similar.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)