[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to use open uri or net/http class

sujeet kumar

6/2/2005 12:04:00 PM

Hi
I am not able to access any http via Ruby program.I access internet
using proxy server. On runniong following program , it generates
error :

c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo:
no address
associated with hostname. (SocketError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from c:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
from c:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
from url.rb:4

require 'net/http'
require 'socket'
h = Net::HTTP.new('www.pragmaticprogrammer.com'', 80)
resp, data = h.get('/index.html', nil )
puts "Code = #{resp.code}"
puts "Message = #{resp.message}"
resp.each {|key, val| printf "%-14s = %-40.40s\n", key, val }
p data[0..55]

How to correct the code


4 Answers

Shajith

6/2/2005 12:23:00 PM

0

Hi!

On 6/2/05, sujeet kumar <sujeetkr@gmail.com> wrote:
> Hi
> I am not able to access any http via Ruby program.I access internet
> using proxy server. On runniong following program , it generates
> error :
>

The standard library documentation for HTTP provides some info. Check out:
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net...

HTH!
Shajith


sujeet kumar

6/2/2005 12:28:00 PM

0

I tried to run the code of the site but it gives me error
require 'net/http'

proxy_addr = 'vsnlproxy.iitk.ac.in'
proxy_port = 3128
:
Net::HTTP::Proxy(proxy_addr, proxy_port).start('www.example.com') {|http|
# always connect to your.proxy.addr:8080
:
}
Error:
c:/ruby/lib/ruby/1.8/uri/common.rb:432:in `split': bad URI(is not
URI?): (URI::
InvalidURIError)
from c:/ruby/lib/ruby/1.8/uri/common.rb:481:in `parse'
from url.rb:7
How to correct error ?


On 6/2/05, Shajith <demerzel@gmail.com> wrote:
> Hi!
>
> On 6/2/05, sujeet kumar <sujeetkr@gmail.com> wrote:
> > Hi
> > I am not able to access any http via Ruby program.I access internet
> > using proxy server. On runniong following program , it generates
> > error :
> >
>
> The standard library documentation for HTTP provides some info. Check out:
> http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net...
>
> HTH!
> Shajith
>
>


Shajith

6/2/2005 12:43:00 PM

0

Hi

On 6/2/05, sujeet kumar <sujeetkr@gmail.com> wrote:
> I tried to run the code of the site but it gives me error
> require 'net/http'
>
> proxy_addr = 'vsnlproxy.iitk.ac.in'

Could you try with an "http://" prefixed to that?

Shajith


Siobhan Medeiros (Shannon Mitchell) Work: Always On UPS Systems, #100 - 150 Campion Rd, Kelowna, BC,

7/24/2011 3:34:00 AM

0

The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

On Fri, 22 Jul 2011 01:25:09 -0700 (PDT), Siobhan Medeiros
<shanbo1926@gmail.com> wrote:
>John Adams said that democracy couldn't work without public
>education.

Oops! Caught lying:

"A better system of education for the common people might preserve
them long from such artificial inequalities as are prejudicial to
society, by confounding the natural distinctions of right and wrong,
virtue and vice." John Adams, letter to Count Sarsfield, February 3,
1786

"Laws for the liberal education of the youth, especially of the lower
class of the people, are so extremely wise and useful, that, to a
humane and generous mind, no expense for this purpose would be thought
extravagant." John Adams, Thoughts on Government, 1776
http://www.marksquotes.com/Founding-Fathers/Adams/...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...