Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This hook function gives the choice to set the pointer to the application data (with p_data argument) that the µC/HTTP-client stack will take care of transferring; or to directly copy the data in the HTTP transmit buffer (with p_buf argument).

Prototype

Code Block
          CPU_BOOLEAN  HTTPc_ReqBodyHook (HTTPc_CONN_OBJ   *p_conn_obj,
        
                                 HTTPc_REQ_OBJ    *p_req_obj,
                                          void            **p_data,
      
                                   CPU_CHAR         *p_buf,
     
                                    CPU_INT16U       *p_buf_len  
                                          CPUCPU_INT16U       *p_data_len);


Arguments

...

Example Template

Code Block
languagecpp
titleListing - Request Body Callback Function Example Code
linenumberstrue
CPU_CHAR  AppHTTPc_ReqBodyBuf[1024];


static  CPU_BOOLEAN  HTTPc_ReqBodyHook (HTTPc_CONN_OBJ   *p_conn,
                                        HTTPc_REQ_OBJ    *p_req,
                                        void            **p_data,
                                        CPU_CHAR         *p_buf,
                                        CPU_INT16U        buf_len,
                                        CPU_INT16U       *p_data_len)
{
    CPU_SIZE_T  data_len;

    data_len   = App_ReadDataStream(&AppHTTPc_ReqBodyBuf);   /* Theoretical application's function to read a stream of data and  ... */
                                                             /* ... copy it in the buffer and return the length of data copied.      */

   *p_data     = &AppHTTPc_ReqBodyBuf;
   *p_data_len = data_len;

    if (data_len == 0) {
        return (DEF_YES);
    } else {
        return (DEF_NO);
    }
}

...