DevTest VSE response header not accepting transfer-encoding as chunked
search cancel

DevTest VSE response header not accepting transfer-encoding as chunked

book

Article ID: 136424

calendar_today

Updated On:

Products

CA Application Test Service Virtualization

Issue/Introduction

 

Need to provide transfer-encoding as chunked in the response header but the service is giving a "bad chunk" error after providing the corresponding header in response. 

 



Environment

All supported DevTest releases.

Cause

Need to carefully construct the responses.  

Resolution

Chunked response needs the following header:

Transfer-Encoding: chunked

Since, chunked response is typically used when the content length is not known upfront, there is no need to set content-length response header.

The most important aspect of chunked response is to carefully construct the response.

This is how a chunked response looks like:

Lets understand how to craft the response:

chunked

Data is sent in a series of chunks. The Content-Length header is omitted in this case and at the beginning of each chunk you need to add the length of the current chunk in hexadecimal format, followed by '\r\n' and then the chunk itself, followed by another '\r\n'. The terminating chunk is a regular chunk, with the exception that its length is zero. It is followed by the trailer, which consists of a (possibly empty) sequence of header fields.

So, the first chunk in the screenshot above has content as 'Mozilla' whose length is 7 characters. So, the first line should be <7 in hex> \r \n

Followed by the actual content and then followed by \r \n

Like this, multiple chunks can be framed.

The end of chunk needs to indicated with a termination character marking.

0 followed by \r \n

and then another \r \n

The challenge was to frame the response in the VSI file:

Shown below is how the response appears in the VSI file:

Note: The attached MAR file has a single HTTP transaction that uses chunked response. To invoke the VS method, use the URL: http://localhost:8001/v2/pet/1

Attachments

ChunkedResponseDemo.mar get_app