Share this page

# web_reg_async_attributes

Asynchronous Functions - C

Registers the next action function as the beginning of an Asynchronous 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. if the function has requests with the specified URL.

`int web_reg_async_attributes( "ID=id", "URL[/RE][/IC]=URL_or_RegEx_Pattern", ["Pattern=None|Push|Poll|LongPoll", ["PollIntervalMs=integer"]], ["XMLHttpRequest=No|Async|Sync",] ["CrossStep=No|Yes",] ["RequestCB=function_name",] ["ResponseHeadersCB=function_name",] ["ResponseBodyBufferCB=function_name",] ["ResponseCB=function_name",] LAST);`

Argument | Description
--- | ---
ID | The Conversation ID.
URL | The full absolute URL, exactly as expected in the next action function. If /RE is specified, the URL can be a regular expression. See Regular Expressions. If /IC is specified, the match is not case sensitive.
Pattern | One of `None`, `Push`, `Poll`, or `LongPoll`. See Asynchronous Conversation Patterns.
PollIntervalMs | The number of milliseconds to wait after the end of one poll instance, before another instance can be started.
XMLHttpRequest | Sets whether or not the task is handled as a javascript XMLHttpRequest and handled asynchronously to other tasks. One of `No`, `Async`, or `Sync`. If the Pattern is None or Push, the default is No. If the Pattern is Poll or LongPoll, the default is Async.
CrossStep | If Yes, the steps can end without waiting for the server response for the specified URL to complete. `Yes` or `No`. The default is Yes for all Pattern values except None.
RequestCB | The name of a user-coded C callback function. The specified function is invoked once for each conversation task. The function and can modify the URL and the request body. See Request Callback
ResponseHeadersCB | The name of a user-coded C callback function. The specified function is invoked at most once for each response, when all response headers have been received. See Response Header Buffer Callback
ResponseBodyBufferCB | The name of a user-coded C callback function. The specified function is invoked zero or more times for each response body buffer received. It is invoked with data extracted from the last read buffer, and also invoked with all response body accumulated to this point. It is also invoked once with empty data when the response has ended. See Response Body Buffer Callback
ResponseCB | The name of a user-coded C callback function. The specified function is invoked once at the end of a conversation, with the accumulated response headers and body of the last request in the conversation. If the last request did not return a response, the callback function is invoked and passed an empty string as the callback function argument. See Response Callback
LAST | A marker that indicates the end of the argument list.

## Return Values

This function returns LR_PASS (0) if the registration succeeded.

## Parameterization

The values of keyword-value pairs can be parameterized. For example, "ALT={altParam}".

## General Information

The URL argument is not necessarily the primary URL of the next action function. For example, it can be a redirection or a resource. The Conversation registered will be that specified by the `URL` argument.

## 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: