[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Curious termination on connecting via SSL

Joe Pym

7/2/2007 11:11:00 AM

Hi

Firstly, just wanted to say the documentation on here is great, its
helped me out a lot. However, in my recent code, I've run into a bug
which I can't work out why it is happening. I'm attempting to submit a
POST operation to a secure website. The relevant section is:

begin
site = Net::HTTP.new('securesite.co.uk', 443)
site.use_ssl = true
print 'TEST '
site.start
site.post('/submissionurl', @data.to_s)
site.finish
print 'a'
rescue
print ' ERROR '
else
print ' Working '
ensure
print 'd'
end
print 'a'
end

I get the following output:

*** WARNING *** Windows users should check the "Run process in terminal"
check box in the Debugger Preferences
to see STDOUT and STDERR output in real time.
TEST warning: peer certificate won't be verified in this SSL session
>exit

The interesting thing for me is that it does not matter what I put after
the site.start command, as long as it is syntactically valid, no errors
are thrown(for example site.completegarbage gives the same output).
Also, as far as I can tell, it should print out the 'd' at least,
because it is in an ensure block.

I'm using Ruby version 1.8, installed on Windows XP with the one click
installer. I have already included 'net/https' and 'uri'.

Any help would be greatly appreciated..I don't quite understand how it
is behaving like that.

Regards

Joe

--
Posted via http://www.ruby-....

1 Answer

Phil Meier

7/3/2007 7:41:00 AM

0

> ... in my recent code, I've run into a bug
> which I can't work out why it is happening. I'm attempting to submit a
> POST operation to a secure website. The relevant section is:
>
> begin
> site = Net::HTTP.new('securesite.co.uk', 443)
> site.use_ssl = true
> print 'TEST '
> site.start
> site.post('/submissionurl', @data.to_s)
> site.finish
> print 'a'
> rescue
> print ' ERROR '
> else

what's this else???

> print ' Working '
> ensure
> print 'd'
> end
> print 'a'
> end
>
> I get the following output:
>
> *** WARNING *** Windows users should check the "Run process in terminal"
> check box in the Debugger Preferences
> to see STDOUT and STDERR output in real time.

that comes from your debugger
> TEST warning: peer certificate won't be verified in this SSL session

TEST comes from your "print" statement, "warning: ..." from Net::HTTP.new

> The interesting thing for me is that it does not matter what I put after
> the site.start command, as long as it is syntactically valid, no errors
> are thrown(for example site.completegarbage gives the same output).
> Also, as far as I can tell, it should print out the 'd' at least,
> because it is in an ensure block.

Yes that's true - an ensure part in a begin/end block should always be
called.

Example:

begin
print 'TEST start'
print 'a'
rescue
print ' ERROR '
ensure
print 'd'
end

Regards Phil