CGI Poll

The Poll hook function SHOULD be enable in case the request processing require lots of time. It allows the HTTP server to periodically poll the upper application and verify if the request processing has finished, as shown in the figure Hook Functions. If the Poll feature is not required, this field SHOULD be set as DEF_NULL.

Prototype

CPU_BOOLEAN  HTTPs_ReqRdyPollHook (const  HTTPs_INSTANCE  *p_instance,
                                          HTTPs_CONN      *p_conn,
                                   const  void            *p_hook_cfg);

Arguments

p_instance

Pointer to the instance structure (read only).

p_conn

Pointer to the connection structure.

p_hook_cfg

Pointer to hook application data.

Return Values

DEF_YES

If the request processing is completed and the response can be sent.

DEF_NO

If the request processing is not completed and the Poll function must be called again to know the end of processing.

Required Configuration

See section Hook Configuration.

Notes / Warnings

  • The instance structure is for read-only. It must not be modified.
  • The following connection attributes can be accessed to analyze the connection (see HTTPs_CONN in Control Structures for further details on each parameters):

    • ClientAddr
    • Method
    • PathPtr
    • ReqHdrCtr
    • ReqHdrFirstPtr
    • ConnDataPtr
  • In this hook function, only the under-mentioned connection parameters are allowed to be modified (see HTTPs_CONN in Control Structures for further details on each parameters):
    • StatusCode
    • PathPtr
    • FilePtr
    • FileLen
    • BodyDataType
  • If request data take a while to be processed:

    The poll callback function should be used to allow the HTTP server core to poll periodically the upper application and verify if the request data processing has been completed.
    Note that The ConnDataPtr attribute inside the HTTPs_CONN structure can be used to store a semaphore pointer related to the completion of the request processing.

Example Template

The listing below demonstrates the µC/HTTP-server module capabilities. That code just returns the state of the request processing state, assuming it’s possible to post only one processing at a time.

Listing - CGI Poll Hook Function Example Code
static  CPU_BOOLEAN  req_processing_state = DEF_YES;
          
static  CPU_BOOLEAN  HTTPs_ReqRdyPollHook (const  HTTPs_INSTANCE  *p_instance,
                                                  HTTPs_CONN      *p_conn,
                                           const  void            *p_hook_cfg)
{
   return (req_processing_state)
}