Response Body Buffer Callback

ResponseBodyBufferCB

Example: Asynchronous ConversationsAsynchronous 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 );
ArgumentDescription
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

aHttpStatusCodeThe HTTP status return code.

 

Return Values

Returns a value of WEB_ASYNC_CB_RC_ENUM

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 ConversationClosed 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.).