savonrb / httpi

Common interface for Ruby's HTTP clients
http://httpirb.com
MIT License
300 stars 150 forks source link

HTTPI (at least with default adapter) doesn't automatically send basic auth headers #186

Closed novalis closed 7 years ago

novalis commented 7 years ago

I'm using HTTPI with the default adapter.

request = HTTPI::Request.new(url: url)
request.auth.basic(username, password)
HTTPI.get(request)

This sends a request without an Authorization header. When it gets a 401 back, then it sends the Authorization header. This wastes round-trips. Instead, it should send the Authorization header on the first request.

rogerleite commented 7 years ago

Hi @novalis

In theory, curb adapter sets basic credentials. Spec here and source here. I suspect that username is not set, specs don't cover it.

I'm alone with httpi and I don't have time to see this now. Would you mind to check and open a pull request?

Thanks.

novalis commented 7 years ago

I'm sorry. This is my fault -- I thought I has configured the curb adapter, but in fact, I had not. So the default adapter has this problem, but the 'curb' adapter works correctly. I guess this is still a bug, but it is no longer a bug which affects me, because I need to use the curb adapter.

rogerleite commented 7 years ago

No problem. By default httpi use adapter based on installed gem and load order, maybe you were using some adapter without basic auth support. 👍