3

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

Modifying Session Configuration

... example code ...

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

Ok, I will not use it, but why it is not recommended for handling Authorization headers?

Nykholas
  • 503
  • 1
  • 6
  • 14

1 Answers1

2

There are a couple of reasons why we recommend this.

  1. The session configuration headers should only be set for those that are not going to change throughout the lifecycle of the session such as Accept-Encoding, Accept-Language, User-Agent, etc. If you need to set a header that could possibly change between requests, then you should add that header to the NSURLRequest itself which takes precedence over the session configuration headers.

  2. Modifying the session's configuration headers after the configuration has been created does not behavior consistently between iOS 7 and iOS 8. See this thread for more info.

Hopefully that helps clear things up a bit.

Community
  • 1
  • 1
cnoon
  • 16,575
  • 7
  • 58
  • 66