0
votes

I am facing 1 issue in jmeter header manager. I need to add 1."key=Authorization" with bearer key word in value "value=Bearer ${Token}" 2."key=Authorization" with out bearer key word in value "value=${Token}".

Is it possible to add 2 key with same name? Or any other solution is there?

Errors getting: 1.)If I give both key and value in header-412- precondition. 2.)If I give 1 key and value with bearer-401 unauthorised. 3.)If I give 1 key and value with out bearer-400 Bad request.

I tried by adding 2 header manager one in global and one under http sampler.

1
Add Header Manager as a child below the request. I guess you have added two header manager in the root of the test plan.Adnan

1 Answers

0
votes

According to the RFC7230 document,

A sender MUST NOT generate multiple header fields with the same field name in a message unless either the entire field value for that header field is defined as a comma-separated list [i.e., #(values)] or the header field is a well-known exception (as noted below).

A recipient MAY combine multiple header fields with the same field name into one "field-name: field-value" pair, without changing the the semantics of the message, by appending each subsequent field-value to the combined field value in order, 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; a proxy MUST NOT change the order of these field values when forwarding a message.

You will get 400 bad requests if you send 2 fields with the same name in the header.

Response code: 400
Response message: Bad Request