Conditional test : going crazy

Z

Zouplaz

Hello, I'm goind crazy with this piece of code

response = @http.get(url, headers)
raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" if response.code != 200


The exception is raised even when response.code contains 200 !!

What's wrong ?

Thanks
 
Z

Zouplaz

le 05/09/2006 11:18, Zouplaz nous a dit:
Hello, I'm goind crazy with this piece of code

response = @http.get(url, headers)
raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" if response.code != 200

'200' !!!!!!!!!!!!!!!!!!!!
 
A

Alex Young

Zouplaz said:
Hello, I'm goind crazy with this piece of code

response = @http.get(url, headers)
raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" if response.code != 200


The exception is raised even when response.code contains 200 !!

What's wrong ?
The response code isn't a number, it's a string. Try:

... if response.code != "200"
 
K

Kevin Olbrich

The response code isn't a number, it's a string. Try:

... if response.code != "200"

might as well do this while you are at it...

raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" unless response.code == '200'

_Kevin
www.sciwerks.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top