You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setting httpAdditionalHeaders works about half the time
setting headers via httpRequest.setValue(_, forHTTPHeaderField🙂 works most of the time
but either way, by testing again and again, some requests are sent without headers for what should be identical runs.
Analyzed the issue further. I could see that httpAddionalHeaders are set properly to the URLSession configuration however it is not getting added to the URLRequest. As per the documentation, the httpAddionalHeaders from the session configuration should be inherited to the URLRequest.
The URLRequest can be used with any URLSession and hence cannot be added while creating the request. Also, there is no direct link between URLSession and URLRequest till a dataTask is created. Hence, dataTask is the first opportunity to update the Request with httpAddionalHeaders from the corresponding URLSession configuration.
In NSURLSessionTask, the request can be updated while configuring the connection handle in configureEasyHandle.
In configurEasyHandle, the headers for Request is set by calling curHeaders with request which extract the header information from allHTTPHeaderFields of the request.
The httpAddionalHeaders needs to be overridden if the same header element is updated in the request. This can be achieved if httpAddionalHeaders from the session configuration is added first and then append/update with allHTTPHeaderFields of the request.
Additional Detail from JIRA
md5: 276b8e47a028742e30a0858d5ea53906
Issue Description:
Creating a URLSession configuration and then using configuration.httpAdditionalHeaders to set additional header flags doesn't work.
This problem has also been reported on StackOverflow here:
http://stackoverflow.com/questions/41229814/httpadditionalheaders-not-working-on-linux
The text was updated successfully, but these errors were encountered: