SetNewGetHandler return value

Discussion to talk about software related topics only.
Post Reply
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

SetNewGetHandler return value

Post by seulater »

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;
}
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: SetNewGetHandler return value

Post by dciliske »

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
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: SetNewGetHandler return value

Post by seulater »

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.
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: SetNewGetHandler return value

Post by dciliske »

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
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: SetNewGetHandler return value

Post by seulater »

Sorry, MyDoGet.
roland.ames

Re: SetNewGetHandler return value

Post by roland.ames »

Still no answer to the question

How is the MyDoGet return value interpreted??
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: SetNewGetHandler return value

Post by dciliske »

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
Dan Ciliske
Project Engineer
Netburner, Inc
roland.ames

Re: SetNewGetHandler return value

Post by roland.ames »

Thanks Dan.
Post Reply