Implement callbacks

For a list of protocols that support asynchronous communication, see 64-bit recording, Async, and IPv6 support.

After VuGen scans a Vuser script for asynchronous communication, the Async tab of the Design Studio lists the asynchronous conversations that were found in the script. For each asynchronous conversation found during the scan, VuGen adds the callback function signatures matching those declared in the web_reg_async_attributes step. The signatures are added to the AsyncCallbacks.c extra file.

The names of the callback functions start with the conversation ID of the asynchronous conversation. For example, the RequestCB callback for an asynchronous conversation with ID “LongPoll_0” will be LongPoll_0_RequestCB.

The names of the callback functions are declared in the web_reg_async_attributes step in the script.

The available callbacks are:

  • RequestCB

    This callback is called before a request is sent.

  • ResponseBodyBufferCB

    This callback is called when there is content in the response body buffer and at the end of the response body. This callback is generated by VuGen automatically for push-type conversations, but is available for poll and long-poll conversations as well.

  • ResponseCB

    This callback is called after every response is received in the conversation.

Example 1:

In the following sample code, the three callback functions are declared in the web_reg_async_attributes step.

Example 2:

In the following sample code, the two callbacks are implemented in the AsyncCallbacks.c extra file.

You can modify the callbacks to implement the required behavior. For details, see Modify callbacks.

Example 3:

The following sample code shows an implementation of the ResponseHeader callback function, including the three arguments: HTTP Status code, Accumulated headers string and Accumulated headers string length.

Copy code
int Push_0_ResponseHeadersCB(

   int aHttpStatusCode,

   const char * aAccumulatedHeadersStr,

   int aAccumulatedHeadersLen)


       //Enter your implementation for ResponseHeadersCB() here.

       lr_output_message("Response status code is :[%d]", aHttpStatusCode);

       lr_output_message("Response headers are :/n[%s]", aAccumulatedHeadersStr);




A sample of the output from the above callback function is shown below:

Response status code is :[200]

Response headers are :

[HTTP/1.1 200 OK

Connection: close

Date: Tue, 25 Jun 2013 09:03:33 GMT

Server: Microsoft-IIS/6.0

Content-Type: text/html

Cache-control: private]

Back to top