Why is it not a good idea to change the session configuration for authorization headers in Alamofire?

From: https://github.com/Alamofire/Alamofire

Change session configuration

... sample code ...

This is not recommended for Authorization or Content-Type headers. Use URLRequestConvertible and ParameterEncoding instead, respectively.

Ok, I won't use it, but why is it not recommended for handling authorization headers?

+3


source to share


1 answer


There are several reasons why we recommend this.

  • Session configuration headers should be set only for those who will not change throughout the duration of the life cycle, such as Accept-Encoding

    , Accept-Language

    , User-Agent

    , etc. If you need to set a header that can change between requests, then you must add that header to the header itself NSURLRequest

    , which takes precedence over the session configuration headers.

  • Changing the session configuration headers after the configuration is created does not lead to consistent communication between iOS 7 and iOS 8. See this thread for more information.



Hope this helps to sort things out a bit.

+2


source







All Articles