Currently the request alter callback for a client is called at the beginning of the HttpClient->execute() function. However, after the alter callback is called the client goes on to add several headers. It makes more sense to move the alter callback to immediately before the delegate executes the request so that any of these additional headers may also be removed or altered.

My specific example is that I am submitting a request to an API that expects the POST data to be in the application/JSON format, however it will barf if the 'Accept' header is set to application/JSON. Actually it doesn't want any Accept header at all. Since the Accept header is added after the alter and is based on the formatter's mime type, I have no other way of removing that Accept header.

Here is a simple, git aware patch to move the alter callback.

Comments

acrazyanimal created an issue. See original summary.

acrazyanimal’s picture

Status: Active » Needs review
StatusFileSize
new1.17 KB
acrazyanimal’s picture

Issue summary: View changes