The following PR fixes the issue found in #62 with headers of a request.
Due to a design issue request.headers are removed automatically when a custom request.body is set.
In this example, we set both the Authorization and Content-Type headers.
However, when we set the .body of the request to a multi-part form-encoded, the specific body configuration sets its additional headers (i.e., Content-Length) by replacing the entire HTTPHeaders object with its own instead of merging values.
Our fix decuple the request.headers and request.body.headers in two different objects.
When the URLRequest is generated from a client, values are merged in the following order:
client's headers (customized by the user, shared among all requests executed in that client instance)
request.body's headers (automatically set and optionally customized by the user)
request.header's (set by the user)
A specific unit test was also added to validate the following scenario.
The following PR fixes the issue found in #62 with
headers
of a request.Due to a design issue
request.headers
are removed automatically when a customrequest.body
is set.This is an example of the issue:
In this example, we set both the
Authorization
andContent-Type
headers.However, when we set the
.body
of the request to a multi-part form-encoded, the specific body configuration sets its additional headers (i.e.,Content-Length
) by replacing the entireHTTPHeaders
object with its own instead of merging values.Our fix decuple the
request.headers
andrequest.body.headers
in two different objects.When the
URLRequest
is generated from a client, values are merged in the following order:A specific unit test was also added to validate the following scenario.