Small bug in net/http.rb

I’ve played with Net::HTTP and found little mistype in proxy
authorization method (see attached diff).

I am still don’t know how to follow redirect to new dynamic web host on
the same real host. Is it possible with Net::HTTP?

Best regards,
Eugene Scripnik
IT Group
Tel./Fax +380 (372) 58-43-10
e-mail: Eugene.Scripnik@itgrp.net
http://www.itgrp.net/

http.diff (352 Bytes)

Hi,

From: Eugene Scripnik [mailto:Eugene.Scripnik@itgrp.net]
Sent: Tuesday, February 25, 2003 7:23 PM

I am still don’t know how to follow redirect to new dynamic
web host on
the same real host. Is it possible with Net::HTTP?

Can you tell us the actual site you are testing?

With my module http-access2 (see RAA),
ruby -rhttp-access2
-e ‘p HTTPClient.new.getContent(“http://…”)’
should follow redirect(s). But the script you posted
with Net::HTTP should work as well I think.

Regards,
// NaHi

NAKAMURA, Hiroshi wrote:

I am still don’t know how to follow redirect to new dynamic
web host on
the same real host. Is it possible with Net::HTTP?

Can you tell us the actual site you are testing?

With my module http-access2 (see RAA),
ruby -rhttp-access2
-e ‘p HTTPClient.new.getContent(“http://…”)’
should follow redirect(s). But the script you posted
with Net::HTTP should work as well I think.

ok, i’ll take a look at http-access2. try my script bellow - it fails
with message:
getaddrinfo: No address associated with hostname

fetch.rb:
#!/usr/local/bin/ruby -w

require ‘net/http’
require ‘uri’

uri = ‘http://www.sms.de/
response = Net::HTTP.get_response( URI.parse( uri ) )
while Net::HTTPRedirection === response
puts response[‘Location’]
response = Net::HTTP.get_response( URI.parse( response[‘Location’] ) )
end
p response

NAKAMURA, Hiroshi wrote:

Hi,

From: Eugene Scripnik [mailto:Eugene.Scripnik@itgrp.net]
Sent: Tuesday, February 25, 2003 7:23 PM

I am still don’t know how to follow redirect to new dynamic
web host on
the same real host. Is it possible with Net::HTTP?

Can you tell us the actual site you are testing?

With my module http-access2 (see RAA),
ruby -rhttp-access2
-e ‘p HTTPClient.new.getContent(“http://…”)’
should follow redirect(s). But the script you posted
with Net::HTTP should work as well I think.
Hmm, your sample fails on http://www.sms.de/, I don’t know why.

fetch.rb:
#!/usr/local/bin/ruby -w

pigeon% ruby -w
require 'net/http'
require 'uri'

uri = 'http://www.sms.de/'
response = Net::HTTP.get_response( URI.parse( uri ) )
while Net::HTTPRedirection === response
     puts response['Location']
     response = Net::HTTP.get_response( URI.parse( response['Location'] ) )
end
p response
^D
http://www-737cad4afe3f6c860e968995274d025e.id.sms.de:80/
SMS Versand im Web
http://www-57245dbdce8086d069e4a476c09ff41e.id.sms.de:80/login/refused.php3?log=c
#<Net::HTTPOK 200 readbody=true>
pigeon%

Guy Decoux

ts wrote:

“E” == Eugene Scripnik Eugene.Scripnik@itgrp.net writes:

fetch.rb:
#!/usr/local/bin/ruby -w

pigeon% ruby -w
require ‘net/http’
require ‘uri’

uri = ‘http://www.sms.de/
response = Net::HTTP.get_response( URI.parse( uri ) )
while Net::HTTPRedirection === response
puts response[‘Location’]
response = Net::HTTP.get_response( URI.parse( response[‘Location’] ) )
end
p response
^D
http://www-737cad4afe3f6c860e968995274d025e.id.sms.de:80/
SMS Versand im Web
http://www-57245dbdce8086d069e4a476c09ff41e.id.sms.de:80/login/refused.php3?log=c
#<Net::HTTPOK 200 readbody=true>
pigeon%

Interesting, here is my output:

http://www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de:80/
/usr/local/lib/ruby/1.8/net/protocol.rb:399:in initialize': getaddrinfo: No address associated with hostname (SocketError) from /usr/local/lib/ruby/1.8/net/protocol.rb:399:in new’
from /usr/local/lib/ruby/1.8/net/protocol.rb:399:in connect' from /usr/local/lib/ruby/1.8/net/protocol.rb:398:in timeout’
from /usr/local/lib/ruby/1.8/net/protocol.rb:398:in connect' from /usr/local/lib/ruby/1.8/net/protocol.rb:380:in initialize’
from /usr/local/lib/ruby/1.8/net/protocol.rb:151:in open' from /usr/local/lib/ruby/1.8/net/protocol.rb:151:in conn_socket’
from /usr/local/lib/ruby/1.8/net/http.rb:675:in do_start' from /usr/local/lib/ruby/1.8/net/protocol.rb:131:in start’
from /usr/local/lib/ruby/1.8/net/http.rb:635:in get_by_uri' from /usr/local/lib/ruby/1.8/net/http.rb:621:in get_response’
from ./fetch.rb:10

http://www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de:80/
/usr/local/lib/ruby/1.8/net/protocol.rb:399:in `initialize':
getaddrinfo: No address associated with hostname (SocketError)

How was compiled ruby ? which OS ?

Now www.sms.de use a cookie, and probably you need to propagate this
cookie.

Guy Decoux

ts wrote:

http://www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de:80/
/usr/local/lib/ruby/1.8/net/protocol.rb:399:in `initialize’:
getaddrinfo: No address associated with hostname (SocketError)

How was compiled ruby ? which OS ?
#uname -mrs
FreeBSD 4.7-STABLE i386
#cat compile.sh
#!/bin/sh

env CFLAGS=‘-O -pipe’ ./configure --enable-shared

Now www.sms.de use a cookie, and probably you need to propagate this
cookie.
This was just an example of not working code, I’ll resend cookies when I
get this code to work.

#uname -mrs
FreeBSD 4.7-STABLE i386

I know nothing about *BSD, what give host ?

pigeon% host www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de
www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de CNAME www06.sms.de
!!! www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de CNAME record has zero ttl
www06.sms.de CNAME chief06.farm01.netzquadrat.de
chief06.farm01.netzquadrat.de A 217.10.65.97
pigeon%

Guy Decoux

ts wrote:

“E” == Eugene Scripnik Eugene.Scripnik@itgrp.net writes:

#uname -mrs
FreeBSD 4.7-STABLE i386

I know nothing about *BSD, what give host ?
#host www-003bb5b6303e50326b1171ffba4750e8.id.sms.de
www-003bb5b6303e50326b1171ffba4750e8.id.sms.de is a nickname for
www04.sms.de
www04.sms.de has address 217.10.65.44

···

pigeon% host www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de
www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de CNAME www06.sms.de
!!! www-18fea2c6be4fbed8d7597f5a7fcbd530.id.sms.de CNAME record has zero ttl
www06.sms.de CNAME chief06.farm01.netzquadrat.de
chief06.farm01.netzquadrat.de A 217.10.65.97
pigeon%

#uname -mrs
FreeBSD 4.7-STABLE i386

Well, I really don't know if it's IPv6 enabled try to compile ruby with

  --enable-ipv6 --with-lookup-order-hack=INET

Guy Decoux

ts wrote:

#uname -mrs
FreeBSD 4.7-STABLE i386

Well, I really don’t know if it’s IPv6 enabled try to compile ruby with

–enable-ipv6 --with-lookup-order-hack=INET

IPv6 networking is disabled in kernel on our server. And I don’t realy
understand how all this stuff works, but I can say that this script
works well if I use proxy instead of direct connection.