HTTPExecutePost Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
HTTPExecutePost Function
C
HTTP_IO_RESULT HTTPExecutePost();
Description

This function is implemented by the application developer in CustomHTTPApp.c. Its purpose is to parse the data received from POST forms and perform any application-specific tasks in response to these inputs. Any required authentication has already been validated before this function is called. 

When this function is called, POST data will be waiting in the TCP buffer. curHTTP.byteCount will indicate the number of bytes remaining to be received before the browser request is complete. 

Since data is still in the TCP buffer, the application must call TCPGet or TCPGetArray in order to retrieve bytes. When this is done, curHTTP.byteCount MUST be updated to reflect how many bytes now remain. The functions TCPFind, TCPFindString, TCPFindROMString, TCPFindArray, and TCPFindROMArray may be helpful to locate data in the TCP buffer. 

In general, data submitted from web forms via POST is URL encoded. The HTTPURLDecode function can be used to decode this information back to a standard string if required. If data buffer space associated with this connection is required, curHTTP.data may be overwritten here once the application is done with the values. Any data placed there will be available to future callbacks for this connection, including HTTPExecutePost and any HTTPPrint_varname dynamic substitutions. 

Whenever a POST form is processed it is recommended to issue a redirect back to the browser, either to a status page or to the same form page that was posted. This prevents accidental duplicate submissions (by clicking refresh or back/forward) and avoids browser warnings about "resubmitting form data". Redirects may be issued to the browser by setting curHTTP.data to the destination file or URL, and curHTTP.httpStatus to HTTP_REDIRECT. 

Finally, this function may set cookies. Set curHTTP.data to a series of name/value string pairs (in the same format in which parameters arrive) and then set curHTTP.hasArgs equal to the number of cookie name/value pairs. The cookies will be transmitted to the browser, and any future requests will have those values available in curHTTP.data.

Preconditions

None

Return Values
Return Values 
Description 
HTTP_IO_DONE 
application is done processing 
HTTP_IO_NEED_DATA 
more data is needed to continue, and this function should be called again later 
HTTP_IO_WAITING 
the application is waiting for an asynchronous process to complete, and this function should be called again later 
Remarks

This function is only called when the request method is POST, and is only used when HTTP_USE_POST is defined. This method may NOT write to the TCP buffer. 

This function may service multiple HTTP requests simultaneously. Exercise caution when using global or static variables inside this routine. Use curHTTP.callbackPos or curHTTP.data for storage associated with individual requests. 

 

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.