Friday, November 25, 2011

HTTP authentication with Scala Dispatch

I had some trouble getting basic HTTP authentication to work with the Dispatch library. The documentation and message posts that I've seen say to use the .as(username, password) function on the HTTP request. However, this did not work for me. I had to use the as_! function instead of as. Example:



I believe using as will make a request without authentication, look for a 401 response header, and then re-issue the request with authentication. The Github API, and many others I imagine, do not send a 401 response back when not authenticated.

4 comments:

Timo said...

Thank you so much for this! Saved me at least a day.

Unknown said...

Thx!!! It was very helpful for me! =)

Unknown said...

Thank you so much mate!
Saved me a whole lot of trouble

xz6sf114sj said...

The objective is always to beat the vendor, which suggests getting to—or as shut as potential to—a total point rating of 메리트카지노 21. If your cards total greater than the vendor's cards with out going over 21, you win. If your hand goes over 21, you "bust" and lose your wager.