lib/ftw/request.rb in ftw-0.0.24 vs lib/ftw/request.rb in ftw-0.0.25

- old
+ new

@@ -4,10 +4,11 @@ require "ftw/http/message" require "ftw/namespace" require "ftw/response" require "ftw/protocol" require "uri" # ruby stdlib +require "base64" # ruby stdlib # An HTTP Request. # # See RFC2616 section 5: <http://tools.ietf.org/html/rfc2616#section-5> class FTW::Request @@ -102,9 +103,13 @@ uri = Addressable::URI.parse(uri.to_s) end # TODO(sissel): Use uri.password and uri.user to set Authorization basic # stuff. + if uri.password || uri.user + encoded = Base64.strict_encode64("#{uri.user}:#{uri.password}") + @headers.set("Authorization", "Basic #{encoded}") + end # uri.password # uri.user @request_uri = uri.path # Include the query string, too. @request_uri += "?#{uri.query}" if !uri.query.nil?