When we need a custom handler we use SetNewGetHandler.
Typically like this (see below).
My question is what is the return value used for ?
static http_gethandler * oldhand;
oldhand = SetNewGetHandler( MyDoGet );
/*-------------------------------------------------------------------
Override GET requests to the web server
Parameters:
sock = Handle to open socket connection from client
url = URL client used to get here
rxBuffer = Pointer to the complete HTTP request
------------------------------------------------------------------*/
int MyDoGet( int sock, PSTR url, PSTR rxBuffer )
{
return 0;
}
SetNewGetHandler return value
Re: SetNewGetHandler return value
So, say you need to handle a specific path/page/etc. in a special way, but most of the time you just want to serve the page that's at the target path. The normal handler will handle that, if you use it as a fall through. The return value is to allow this chaining.
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
Re: SetNewGetHandler return value
I have seen examples with return 0 and return 1 and also return ( *oldhand ) ( sock, url, rxBuffer );
so i became curious about the differences between them.
so i became curious about the differences between them.
Re: SetNewGetHandler return value
Er, can you clarify which function you're asking about the return value from? Is it SetNewGetHandler or MyDoGet?
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
Re: SetNewGetHandler return value
Sorry, MyDoGet.
Re: SetNewGetHandler return value
Still no answer to the question
How is the MyDoGet return value interpreted??
How is the MyDoGet return value interpreted??
Re: SetNewGetHandler return value
Hmm... This isn't like me to leave a question unanswered. Anyways, the reason for the return value is once upon a time it was requested that the get handler have the ability to not close the socket when it finished (like transferring a 500MB file using a secondary task). The return value determines what to do. In the event that the get handler returns 2, the webserver will not terminate the connection, with the understanding that the socket is now owned by a different task. And no, I don't know why 2 was chosen and/or why this wasn't documented. 0 and 1 appear to have, once upon a time, been used in internal diagnostics, but are as of now unused.
Hope that clears up some of the confusion. :/
-Dan
Hope that clears up some of the confusion. :/
-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc