rubymotion/BubbleWrap — pull request #199 by EddM (2013-04-21 00:18:33+00:00)
Title: BW::HTTP: Proactively present credentials before challenge

I'm developing against an API that uses HTTP Basic authentication, but it seems `BW::HTTP` will only present the given `:credentials` if the server responds with a 401 on the initial request.

I know the HTTP spec *recommends* (but not does *mandate*) waiting for a challenge first, but it seems kind of wasteful to send two requests when you know for sure the server requires authentication. I'd be happy to implement a `present_credentials: true` option, or something like that, for BubbleWrap if people agree that should be an option?

As a side note, I found a weird thing I cannot explain. In my specs, `BW::HTTP::Query` doesn't seem to send the second request (with the `Authentication` header) after initially receiving the 401 -- but the exact same code does when running it, for example, in the REPL. In practicality, we plan to mock these requests in our specs, but I thought I would raise it nonetheless because I don't know if this is expected behaviour or not - it seems weird.