On Request Query String

Called to include a Key-Value Pair to the Query String of the ongoing Request.

The parameter HTTPc_PARAM_TYPE_REQ_QUERY_STR_HOOK must be set up using the function HTTPc_ReqSetParam() for the hook function to be called.

Prototype

CPU_BOOLEAN  HTTPc_ReqQueryStrHook (HTTPc_CONN_OBJ   *p_conn_obj,
                                    HTTPc_REQ_OBJ    *p_req_obj,
                                    HTTPc_KEY_VAL   **p_key_val);

Arguments

p_conn_obj

Pointer to the current HTTPc Connection Object.

p_req_obj

Pointer to the current HTTPc Request Object.

p_key_val

Variable that will received the pointer to the Key-Value Pair to include in the Query String.

Return Values

DEF_YES, if all the Key-Value Pairs have been passed by the application.

DEF_NO,   if Key-Value Pairs remain to be passed by the application (Hook function will be called again).

Required Configuration

Notes / Warnings

  • The Key-Value Pair object MUST stay valid until the HTTP transaction is completed.

Example Template

Listing - Query String Request Callback Function Example Code
#define  HTTPc_QUERY_STR_KEY_LEN_MAX    10
#define  HTTPc_QUERY_STR_VAL_LEN_MAX    20

HTTPc_KEY_VAL  HTTPc_KeyVal;
CPU_CHAR       HTTPc_KeyStr[HTTPc_QUERY_STR_KEY_LEN_MAX];
CPU_CHAR       HTTPc_ValStr[HTTPc_QUERY_STR_VAL_LEN_MAX];


static  CPU_BOOLEAN  HTTPc_ReqQueryStrHook (HTTPc_CONN_OBJ   *p_conn,
                                            HTTPc_REQ_OBJ    *p_req,
                                            HTTPc_KEY_VAL   **p_key_val)
{
    HTTPc_KEY_VAL  *p_kvp;


    p_kvp         = &HTTPc_KeyVal;
    p_kvp->KeyPtr = &HTTPc_KeyStr[0];
    p_kvp->ValPtr = &HTTPc_ValStr[0];

    Str_Copy_N(p_kvp->KeyPtr, "Name", HTTPc_QUERY_STR_KEY_LEN_MAX);
    Str_Copy_N(p_kvp->ValPtr, "John", HTTPc_QUERY_STR_VAL_LEN_MAX);

    p_kvp->KeyLen = Str_Len_N(p_kvp->KeyPtr, HTTPc_QUERY_STR_KEY_LEN_MAX);
    p_kvp->ValLen = Str_Len_N(p_kvp->ValPtr, HTTPc_QUERY_STR_VAL_LEN_MAX);

   *p_key_val = p_kvp;

    return (DEF_YES);
}