support for basic auth in get request?
Closed this issue · 2 comments
maxstudener commented
Not sure why this isn't working or maybe I am holding something wrong. My server is not getting the http basic auth creds, any idea?
http = Net::HTTP::Persistent.new
uri = URI( URI.escape( SCHEMA + '://' + USERNAME + ':' + PASS + '@' + DOMAIN + URL_PATH + "?" + params.map { |k, v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&') ))
http.read_timeout = 30
http.request uri
BoGs commented
Just build the request and attach the basic_auth
to it as in this example.
You could do http.request <your built request>
drbrain commented
Yes, or use mechanize wraps net-http-persistent and supports specifying which passwords belong to which URLs and realms.