HTTPs_RespBodySetParamFile

Set the parameters to specify a file (contain in a File System) as the body to the HTTP response to send.

This function will changed the following parameters of the HTTPs_CONN structure object :

  • RespBodyDataType
  • PathPtr
  • RespContentType
  • Flags (the HTTPs_FLAG_RESP_CHUNKED flag)

The PathPtr parameter will be used by the HTTP server to found the file stored in the File System.

Files

http-s.h / http-s.c

Prototype

          void  HTTPs_RespBodySetParamFile (const  HTTPs_INSTANCE     *p_instance,
                                                   HTTPs_CONN         *p_conn,
                                                   CPU_CHAR           *p_path,
                                                   HTTP_CONTENT_TYPE   content_type,
                                                   CPU_BOOLEAN         token_en,
                                                   HTTPs_ERR          *p_err);


Arguments

p_instance

Pointer to the HTTP server instance structure.

p_conn

Pointer to the connection structure.

p_path

Pointer to the path string of the file. This string must contains the path to the file and the file name with the extension.

content_type

Content type of the file. It can be set to HTTP_CONTENT_TYPE_UNKNOWN and the HTTP server will check for the file extension to set the Content Type.

See enumeration HTTP_CONTENT_TYPE in http-s.h.

token_en

DEF_YES, if the file must be parse by the HTTP server for token to replace. The response body will be sent with the Chunked Transfer Encoding.
DEF_NO,   otherwise. The response body will be sent the standard way (with the header Content-Length).

p_err

Pointer to variable that will receive the return error code.

Returned values

None.

Required Configuration

None.

Notes / Warnings

Must be called from a callback function only. Should be called by the function pointed by OnReqHook or OnReqRdySignalHook in the Hook Configuration of the instance configuration. The instance lock must be acquired before calling this function. It is why this function must be called from a callback function.

Example Usage

See hook function example, section Response Body Data.