Conditional test : going crazy

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

'200' !!!!!!!!!!!!!!!!!!!!

···

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

Zouplaz wrote:

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"

···

--
Alex

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

···

On Tuesday, September 05, 2006, at 6:29 PM, Alex Young wrote:

Zouplaz wrote:

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"

--
Alex

--
Posted with http://DevLists.com. Sign up and save your mailbox.