Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
to chech the url is valid when using Net::HTTP.get_response
Mano Ah
8/14/2008 6:23:00 AM
I am using Net::HTTP.get_response( URI.parse( url ) ) to get the reponse
from
a website. I have to test it with invalid url. How can i handle it if an
ivalid url is provided and to give and error message.
def method
response = Net::HTTP.get_response( URI.parse( url ) )
r = 3; while r> 0 and
( response.is_a? Net::HTTPFound or
response.is_a? Net::HTTPSeeOther )
location = URI.parse( response[ 'location' ] )
cookie = response.get_fields( 'Set-Cookie' )
cookie.map! { | c | c.split( ';' ).first }
cookie = cookie.join( '; ' )
end
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
to chech the url is valid when using Net::HTTP.get_response
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password