From: Ben Aroia Date: 2008-04-11T08:18:14+09:00 Subject: Re: User Agent String Eric Hodel wrote: > On Apr 10, 2008, at 07:56 AM, Ben Aroia wrote: >> and all it gives me is: >> SocketError: getaddrinfo: No address associated with nodename > > Net::HTTP#initialize takes a host and a port, not URI and port: > > $ ruby > require 'net/http' > h = Net::HTTP.new 'google.com', 'http' > resp, data = h.get '/', "User-Agent" => "Ruby/#{RUBY_VERSION}" > p resp, data > # > "[...][...]" > $ Putting that into irb gives me: => [#, "\n\n400 Bad Request\n\n

Bad Request

\nYour browser sent a request that this server could not understand.

\nClient sent malformed Host header

\n\n"] I've had some luck with open-uri, but I still want to get the error code's from the site. I would really like to be able to create generic HTTP requests, but it's quite daunting. -- Posted via http://www.ruby-forum.com/.