From: Matt Todd Date: 2008-04-11T04:01:29+09:00 Subject: Re: Ruby HTTP GET Headers Hi Ben, I'm not sure if your code would work like you expect it to, but I've written a client library for my Halcyon project you might find interesting. http://github.com/mtodd/halcyon/tree/master/lib/halcyon/client.rb Note that you won't need to use JSON.parse for the response data (that's something peculiar to Halcyon) and that you may get errors if you don't remove #to_mash calls because that's a dependency fulfilled by Merb's Core Extensions. There may be other dependencies that I haven't thought about that will cause problems, but you should be able to determine that from the errors when run. You can get it working with: c = Halcon::Client.new('http://google.com:80/') puts c.get('/') Matt Todd On Thu, Apr 10, 2008 at 10:46 AM, Ben Aroia wrote: > I've looked here: http://snippets.dzone.com/posts/show/788 and I'm not > really understanding it. I am creating a client for a website, and I > want to set the User-Agent field of the header I am sending. Is there a > simple way to do this or is this along the lines of creating custom HTTP > objects? I've also looked into the open-uri class, but I get this error: > Errno::EHOSTDOWN: Host is down - connect(2) > > method initialize in http.rb at line 560 > method open in http.rb at line 560 > method connect in http.rb at line 560 > method timeout in timeout.rb at line 48 > method timeout in timeout.rb at line 76 > method connect in http.rb at line 560 > method do_start in http.rb at line 553 > method start in http.rb at line 542 > method open_http in open-uri.rb at line 242 > method buffer_open in open-uri.rb at line 626 > method open_loop in open-uri.rb at line 164 > method catch in open-uri.rb at line 162 > method open_loop in open-uri.rb at line 162 > method open_uri in open-uri.rb at line 132 > method open in open-uri.rb at line 528 > method open in open-uri.rb at line 30 > at top level in rubyheader.rb at line 8 > > I attached the test file I am working on. Any help would be great. > Thanks. > > Attachments: > http://www.ruby-forum.com/attachment/1716/rubyheader.rb > > -- > Posted via http://www.ruby-forum.com/. > >