{"action":"opened","issue":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/788","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/788/labels{/name}","comments_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/788/comments","events_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/788/events","html_url":"https://github.com/Alamofire/Alamofire/issues/788","id":107245394,"number":788,"title":"Alamofire 2.0 Authorization-Header not sent iOS 9","user":{"login":"eburi","id":699615,"avatar_url":"https://avatars.githubusercontent.com/u/699615?v=3","gravatar_id":"","url":"https://api.github.com/users/eburi","html_url":"https://github.com/eburi","followers_url":"https://api.github.com/users/eburi/followers","following_url":"https://api.github.com/users/eburi/following{/other_user}","gists_url":"https://api.github.com/users/eburi/gists{/gist_id}","starred_url":"https://api.github.com/users/eburi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eburi/subscriptions","organizations_url":"https://api.github.com/users/eburi/orgs","repos_url":"https://api.github.com/users/eburi/repos","events_url":"https://api.github.com/users/eburi/events{/privacy}","received_events_url":"https://api.github.com/users/eburi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-18T17:39:22Z","updated_at":"2015-09-18T17:39:22Z","closed_at":null,"body":"Using\r\n```\r\nPODS:\r\n  - Alamofire (2.0.1)\r\n``` \r\n\r\nI have this strange issue, that the Authorization-Header isn't sent *for some requests*. \r\n\r\nJust upgraded to Alamofire 2.0.1 from 1.3. Had the same problem with the 1.3 on iOS 9 - one specific request does not get the Header sent...\r\n\r\nI tried both ways of setting the header. a) Using a dedicated Manager created with: \r\n```\r\n    func createManagerWithAuthHeader(authHeader:String) -> Manager {\r\n        var addedHeaders = Manager.defaultHTTPHeaders\r\n        addedHeaders[\"Authorization\"] = authHeader\r\n        \r\n        NSLog(\"Authorization-Header: \\(authHeader)\")\r\n        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()\r\n        configuration.HTTPAdditionalHeaders = addedHeaders        \r\n        return Manager(configuration: configuration)\r\n    }\r\n```\r\n\r\nNow I just keep the different values for Authentication and apply them depending on the  route:\r\n```\r\n    // Router to generate Requests\r\n    enum Router: URLRequestConvertible {\r\n        static let BASE_URL = \"************\"\r\n        \r\n        // Possible Requests\r\n        ....\r\n        case Category(String)\r\n        case Criterias(String)\r\n        ....\r\n\r\n        var URLRequest: NSMutableURLRequest {\r\n            let (path, method, userAuth, parameters, encoder): (String, String, Bool, [String: AnyObject], Alamofire.ParameterEncoding) = {\r\n                switch self {\r\n                .....\r\n                case .Category(let catId):\r\n                    return (\"/categories/\\(catId)/\", \"GET\", false, [:], Alamofire.ParameterEncoding.URL)\r\n                case .Criterias(let catId):\r\n                    return (\"/categories/\\(catId)/criteria\", \"GET\", false, [:], Alamofire.ParameterEncoding.URL)\r\n                .....\r\n                }\r\n            }()\r\n            \r\n            let requestUrl = NSURL(string: Router.BASE_URL)\r\n            let request = NSMutableURLRequest(URL: requestUrl!.URLByAppendingPathComponent(path))\r\n            request.HTTPMethod = method\r\n            \r\n            let authHeader = userAuth ? Client.sharedInstance.userAuthHeader : Client.sharedInstance.clientAuthHeader\r\n            request.setValue(authHeader, forHTTPHeaderField: \"Authorization\")\r\n            \r\n            let encoding = encoder\r\n            let encodedRequest = encoding.encode(request, parameters: parameters).0\r\n            return encodedRequest\r\n        }\r\n    }\r\n```\r\n\r\nThe funny thing is, that the call with ```.Category``` works. Here's the code:\r\n```\r\n    func getCategory(categoryId:String, completion: (Category?, ErrorType?) -> Void) {\r\n        let route = Router.Category(categoryId)\r\n        let request = route.URLRequest\r\n        let authHeader = request.valueForHTTPHeaderField(\"Authorization\")\r\n        NSLog(\"getCategory: \\(request) - \\(authHeader)\")\r\n        Alamofire.request(route)\r\n            .responseObject { (category:Category?, meta:JoixesMetaData?, error: ErrorType?) -> Void in\r\n                if error != nil || category == nil {\r\n                    completion(nil, error)\r\n                }\r\n                else {\r\n                    completion(category, nil)\r\n                }\r\n            }\r\n    }\r\n```\r\n\r\nFirst request on the wire (Wireshark):\r\n```\r\nGET /api/v1/categories/_VWypVvLTnWSM7kcK2NuJAl_/? HTTP/1.1\r\nHost: ****\r\nConnection: keep-alive\r\nAccept: */*\r\nUser-Agent: Joixes/com.joixes.Joixes (3; OS Version 9.0 (Build 13A340))\r\nAccept-Language: en-US;q=1.0\r\nAuthorization: Basic Umctb25nQkxRYmF......\r\nAccept-Encoding: gzip;q=1.0,compress;q=0.5\r\n\r\nHTTP/1.0 200 OK\r\nDate: Fri, 18 Sep 2015 17:01:54 GMT\r\nServer: WSGIServer/0.2 CPython/3.4.3\r\nAllow: GET, HEAD, OPTIONS\r\nX-Frame-Options: SAMEORIGIN\r\nVary: Accept\r\nContent-Type: application/json\r\n\r\n{\"data\":{\"uid\":\"_VWypVvLTnWSM7kcK2NuJAl_\",\"name\":\"Clutches\",\"longName\":\"Women, Clutches\",\"parentCategory\":\"TF6thQUmTyiwJt10QsmLJgdC\",\"verticalCategory\":\"x23Un1lcSGSTideM2RQdJw7N\",\"isFindable\":true,\"hasChild\":false,\"childCategories\":[]},\"meta\":{\"detail\":\"Success.\",\"code\":200,\"success\":true}}\r\n```\r\n\r\n\r\nAnd with Criterias it does not work:\r\n```\r\n    func getCriteriasForCategory(categoryId:String, completion: ([BaseFilterCriteria], ErrorType?) -> Void) {\r\n        let route = Router.Criterias(categoryId)\r\n        let request = route.URLRequest\r\n        let authHeader = request.valueForHTTPHeaderField(\"Authorization\")\r\n        NSLog(\"getCriteriasForCategory: \\(request) - \\(authHeader)\")\r\n        Alamofire.request(route)\r\n            .responseJoixes { (jxResponse, error) -> Void in\r\n                NSLog(\"getCriteriasForCategory: jxResponse: \\(jxResponse)\")\r\n                var criterias:[BaseFilterCriteria] = []\r\n                if let criteriaData = jxResponse?.data as? [AnyObject] {\r\n                    criterias = criteriaData.map { return CriteriaFactory.parseCriteria($0 as! [String:AnyObject]) }\r\n                }\r\n                completion(criterias, error)\r\n            }\r\n    }\r\n```\r\n\r\nNote:  **The Authorization-Header in the variable authHeader is correct!! With both requests the exact same value** \r\n\r\nOn the wire there is not :\r\n```\r\nGET /api/v1/categories/_VWypVvLTnWSM7kcK2NuJAl_/criteria/ HTTP/1.1\r\nHost: *****\r\nAccept-Language: en-US;q=1.0\r\nUser-Agent: Joixes/com.joixes.Joixes (3; OS Version 9.0 (Build 13A340))\r\nAccept: */*\r\nAccept-Encoding: gzip;q=1.0,compress;q=0.5\r\nConnection: keep-alive\r\n\r\nHTTP/1.0 401 UNAUTHORIZED\r\nDate: Fri, 18 Sep 2015 17:02:03 GMT\r\nServer: WSGIServer/0.2 CPython/3.4.3\r\nAllow: GET, OPTIONS\r\nWWW-Authenticate: Token realm=api\r\nX-Frame-Options: SAMEORIGIN\r\nVary: Accept\r\nContent-Type: application/json\r\n\r\n{\"data\":null,\"meta\":{\"detail\":\"Authentication credentials were not provided.\",\"code\":401,\"success\":false}}\r\n````\r\n\r\n\r\nAny Hints where the Header-Value could get lost??"}}