Share this page

# Response Body Buffer Callback

ResponseBodyBufferCB

Asynchronous Functions - C

Called when there is content in the response body buffer and at the end of the response body.

    int <function name> ( IN const char *	aLastBufferStr, IN int		aLastBufferLen, IN const char *	aAccumulatedStr, IN int		aAccumulatedLen, IN int aHttpStatusCode );

Argument | Description
--- | ---
aLastBufferStr | A pointer to one of: A non-empty string containing the pre-processed data from the last-received response buffer. The data can contain NULL bytes (\0). An empty string to denote the end of the response body.
aLastBufferLen | The length of the string pointed-to by aLastBufferStr or zero to denote the end of the response data.
aAccumulatedStr | A pointer to one of: A non-empty string containing the accumulated pre-processed data from the response buffers received to this point. The data can contain NULL bytes (\0). An empty string to denote the end of the response body.
aAccumulatedLen | The length of the string pointed-to by aAccumulatedStr, or zero to denote the end of the response data
aHttpStatusCode | The HTTP status return code.

## Return Values

This function returns a value of WEB_ASYNC_CB_RC_ENUM. For details, see Asynchronous function return values.

## General Information

A response body buffer callback is a user-created function. It is invoked zero or more times for each response body buffer received for the Conversation An Asynchronous Conversation is a series of related web tasks, including tasks caused by redirection. An Asynchronous Conversation starts with the request for the desired response, includes all the requests and responses that are caused by this request (authentication, redirection, and so on) and ends when the desired response is received or when the series of interactions is canceled.. After all of the response body data has been passed to the callback, it is invoked once more with an empty last-buffer string. An empty last-buffer string marks the end of the response body for the current conversation. When the response body is empty, the callback is invoked once to mark the end.

The callback is passed the data extracted from the last read buffer and all response body accumulated to this point.

The response data is processed as follows before being passed to the callback:

- If "Transfer-Encoding: chunked" was specified for the response, any overhead bytes are removed.
- If the response was compressed, it is decompressed. This can leave remainders of data to be handled when more data arrive.
- If required, any decompression remainders from a previous segment are joined to the data of the current segment.
- If required, data is converted to the locale charset.

Chunking overhead or decompression remainders can cause a non-empty received response buffer to yield no data after the processing described above. The callback is not invoked for such buffers.

Decompression can cause the callback to be called multiple times for a single received buffer.

This callback can invoke the utility function Request Callback and any of the general utility functions. See Utility Functions: C Language (lr_) or Utility Functions: JavaScript Language (lr.).

## Example

    The following example illustrates an asynchronous conversation.

Copy code

    /* Added by Async CodeGen.
    ID = Push_0
    ScanType = Recording

    The following URLs are considered part of this conversation:
        http://push.myStream.com/myStream/STREAMING_IN_PROGRESS?LS_session=123456789ABCDE&LS_phase=2903&LS_domain=myStream.com&

    TODO - The following callbacks have been added to AsyncCallbacks.c.
    Add your code to the callback implementations as necessary.
        Push_0_RequestCB
        Push_0_ResponseBodyBufferCB
        Push_0_ResponseHeadersCB
        Push_0_ResponseCB
     */
        web_reg_async_attributes("ID=Push_0",
            "Pattern=Push",
            "URL=http://push.myStream.com/myStream/STREAMING_IN_PROGRESS?LS_session=123456789ABCDE&LS_phase=2903&LS_domain=myStream.com&",
            "RequestCB=Push_0_RequestCB",
            "ResponseHeadersCB=Push_0_ResponseHeadersCB",
            "ResponseBodyBufferCB=Push_0_ResponseBodyBufferCB",
            "ResponseCB=Push_0_ResponseCB",
            LAST);

    /* Added by Async CodeGen.
    ID = Push_0
     */
        web_stop_async("ID=Push_0",
            LAST);

    //Automatically generated file for implementing async callback functions.
    //You may modify the added callback implementations or add new ones.
    //Async callback functions may be registered in web_reg_async_attributes steps.
    int Push_0_RequestCB()
    {
        //enter your implementation for RequestCB() here

        //call web_util_request_set_url() here to modify request url:
        web_util_set_request_url("<request url>");

        //call web_util_set_request_body() here to modify request body:
        web_util_set_request_body("<request body>");

        //call web_util_set_request_header() here to set request header:
        web_util_set_request_header("<header_name>", "<header_value>");

        return WEB_ASYNC_CB_RC_OK;
    }
    int Push_0_ResponseHeadersCB(
        int        aHttpStatusCode,
        const char *    aAccumulatedHeadersStr,
        int        aAccumulatedHeadersLen)
    {
        //Enter your implementation for ResponseHeadersCB() here.

        return WEB_ASYNC_CB_RC_OK;
    }

    int Push_0_ResponseBodyBufferCB(
        const char *    aLastBufferStr,
        int             aLastBufferLen,
        const char *    aAccumulatedStr,
        int             aHttpStatusCode)
    {
        //enter your implementation for ResponseBodyBufferCB() here

        return WEB_ASYNC_CB_RC_OK;
    }

    int Push_0_ResponseCB(
        const char *    aResponseHeadersStr,
        int             aResponseHeadersLen,
        const char *    aResponseBodyStr,
        int             aResponseBodyLen,
        int             aHttpStatusCode)
    {
        //enter your implementation for ResponseCB() here
        return WEB_ASYNC_CB_RC_OK;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: