TCPIP_HTTP_PostExecute Function
C
HTTP_IO_RESULT TCPIP_HTTP_PostExecute(
HTTP_CONN_HANDLE connHandle
);
Description
This function is implemented by the application developer. Its purpose is to aprse 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. The connection byteCount (see TCPIP_HTTP_CurrentConnectionByteCountGet) will indicate the number of bytes remaining to be read before the browser request is complete.
Since data is still in the TCP buffer, the application must call TCPIP_TCP_ArrayGet in order to retrieve bytes. When this is done, connection byteCount MUST be updated to reflect how many bytes now remain. The functions TCPIP_TCP_ArrayFind and TCPIP_TCP_Find may be helpful to locate data in the TCP buffer.
In general, data submitted from web forms via POST is URL encoded. The TCPIP_HTTP_URLDecode 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, the connection data buffer (see TCPIP_HTTP_CurrentConnectionDataBufferGet()) 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 TCPIP_HTTP_PostExecute and any TCPIP_HTTP_Print_varname dynamic substitutions.
Whenever a POST from 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 warning about "resubmitting form data". Redirects may be ussued to the browser by setting the connection data buffer to the destination file or URL, and the connection httpStatus (TCPIP_HTTP_CurrentConnectionStatusSet()) to HTTP_REDIRECT.
Finally, this function may set cookies. Set the connection data buffer to a series of name/value string pairs (in the same format in which parameters arrive), and then set the connection hasArgs (TCPIP_HTTP_CurrentConnectionHasArgsSet) 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 the connection data buffer.
Preconditions
None.
Parameters
Parameters | Description |
---|---|
connHandle | HTTP connection handle. |
Returns
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 the connection callbackPos (TCPIP_HTTP_CurrentConnectionCallbackPosGet) or connection data buffer for storage associated with individual requests.