Allow duplicate headers in a test step not using setAllowDupes
search cancel

Allow duplicate headers in a test step not using setAllowDupes

book

Article ID: 129926

calendar_today

Updated On:

Products

CA Application Test CA Continuous Application Insight (PathFinder) Service Virtualization

Issue/Introduction

While trying to duplicate a header key on a test case request, HD1=HV1 and HD1= HV2, are using setAllowDupes (true), but it is accepting only HD1=HV2.

It does not allow to use the duplicate header values.

Need to have more than one header with the same key name and different values.  

Environment

All supported DevTest releases.

Cause

N/A

Resolution

When using a test step with multiple header keys with the same name and different values, just the last header value is being sent to the target endpoint.  

When using one header key with multiple values separated by comma, all the headers values are being sent to the target endpoint.  

Here is an example:

Multiple headers rows, same key name and different values - just the last header was sent:  
metaData=HTTP-Method=POST&...&HD1=1234&Content-Length=2331...   

One header row, one key name and multiple values separated by comma - all the headers are being sent in the request:  
metaData=HTTP-Method=POST&...&HD1=12, 123, 1234&Content-Length=2331...  

As per RFC 2616 - https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
"Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded." 

With that, we do not need to use the setAllowDupes in a test case to allow duplicate headers, but provide the header values separated by comma, like HD1: HV1, HV2, HV3