Forum: Ruby on Rails Reading URL after Doing HTTP Basic Authentication

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0302b7a7f2b0264240b98e63ac8f7868?d=identicon&s=25 Kiran (Guest)
on 2007-03-27 22:34
Hi,

    I am trying to read content of url after doing http authentication.
using
    the below code query string(UserID=1) is not passed properly in the
request.
    I am new to ruby so please let me know what are the changes that
have to
    be done


    test_username='testuser1'
    test_password='password'
    url = URI.parse('http://www.someurl456.com/apps/GetName?UserID=1')

    req = Net::HTTP::Get.new(url.path)
    req.basic_auth test_username, test_password
    res = Net::HTTP.new(url.host, url.port).start {|http|
http.request(req) }
    response=res.body


     If http authentication is not required i can try:
    response=open("http://www.someurl456.com/apps/GetName?UserID=1'")...

Thanks
Kiran
8bc543795b502900b5333aea73ad5533?d=identicon&s=25 Eden Li (edenli)
on 2007-03-28 04:14
(Received via mailing list)
The problem is when you generate the Net::HTTP::Get object, pass in
url.request_uri, not url.path.  #path will only give you the strict
path minus the query string.  #request_uri gives you everything you
need.
This topic is locked and can not be replied to.