Is it normal that every HTTP request is executed twice using Alamofire? One without the authorization header and the other with it?

Viewed 226

When I execute an HTTP request with an authorization token as a header, using Alamofire, the request is executed twice:

1) the first execution without the authorization, gets a 401 status code

2) the second with the authorization included, gets the expected 200

Is that normal or is that a bug? If that is normal, could that be disabled? Is that recommended?

    myNewRequest.headers["Authorization"] = token

    SessionManager.default.request(newRequest)
    .validate()
    .response(queue: DispatchQueue.main) { _ in
        // handle request
    }
0 Answers
Related