This queue is for tickets about the POE-Component-Client-HTTP CPAN distribution.

Report information
The Basics
Id:
76540
Status:
open
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
kozunov [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.945
Fixed in:
(no value)



Subject: return http code 400 when ssl error occure
When I check domain https://intranet.merlion.ru/ version(0.893) return http code 500 (ssl handshake error), but new version(0.945) return http code 400 (Incomplete response - $request_id) and this is confused. It's occure because POE::Component::SSLify now use non-blockig socket. In this case Net::SSLeay::connect could return -1 and we catch error in sub _poco_weeble_io_error when try read from socket. I want to distinguish ssl error from a real incomplete response, but I can't.
Verified with this test program: #!/usr/bin/perl use warnings; use strict; use HTTP::Request::Common qw( GET ); use POE qw( Component::Client::HTTP ); POE::Component::Client::HTTP->spawn(Alias => "ua"); my $requiringURL = 'https://intranet.merlion.ru/'; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->post( ua => request => got_response => GET($requiringURL) ); }, got_response => sub { my $response = $_[ARG1]->[0]; warn $response->as_string(); $_[KERNEL]->post(ua => 'shutdown'); }, } ); POE::Kernel->run(); exit(0); ... Output is a 400 error: % perl rt76540.t 400 Bad Request X-PCCH-Errmsg: Incomplete response - 1 <html> <HEAD><TITLE>Error: Bad Request</TITLE></HEAD> <BODY> <H1>Error: Bad Request</H1> Incomplete response - 1 <small>This is a client error, not a server error.</small> </BODY> </HTML> 1) macbookpoe:~/projects/misc/support%
I added a callback to the Client_SSLify() call that should trigger an error response, but it isn't being called. I've commented it out for now. I'm not sure how to get it working. If you (or someone you know) is familiar with non-blocking Net::SSLeay or POE::Component::SSLify, please have them contact me.
From: kozunov@gmail.com
Пнд Май 14 20:50:01 2012, RCAPUTO писал:
Show quoted text
> I added a callback to the Client_SSLify() call that should trigger an > error response, but it isn't being called. I've commented it > out for now. I'm not sure how to get it working. If you (or someone > you know) is familiar with non-blocking Net::SSLeay or > POE::Component::SSLify, please have them contact me.
I don't know how could catch error in SSLify. So I've patched sub _poco_weeble_io_error 545a546,566
Show quoted text
> if ($request->scheme eq 'https' && $request->wheel) { > my $socket = $request->wheel->get_input_handle; > if ($socket) { > my $error =
Net::SSLeay::get_error(POE::Component::SSLify::SSLify_GetSSL($socket), POE::Component::SSLify::SSLify_GetStatus($socket));
Show quoted text
> # returns: result code, which is one of the following values: > # 0 - SSL_ERROR_NONE > # 1 - SSL_ERROR_SSL > # 2 - SSL_ERROR_WANT_READ > # 3 - SSL_ERROR_WANT_WRITE > # 4 - SSL_ERROR_WANT_X509_LOOKUP > # 5 - SSL_ERROR_SYSCALL > # 6 - SSL_ERROR_ZERO_RETURN > # 7 - SSL_ERROR_WANT_CONNECT > # 8 - SSL_ERROR_WANT_ACCEPT > if ($error) { > $request->connect_error('sslify', $error, 'ssl error'); > return; > } > } > } >
I don't sure that it's a true way, but for my purpose this is enough.
I made the following change, but it didn't affect the test program's output at all. --- a/lib/POE/Component/Client/HTTP.pm +++ b/lib/POE/Component/Client/HTTP.pm @@ -561,6 +561,34 @@ sub _poco_weeble_io_error { # If there was a non-zero error, then something bad happened. Post # an error response back, if we haven't posted anything before. +# if ($request->scheme eq 'https' and $request->wheel) { +# my $socket = $request->wheel->get_input_handle; +# if ($socket) { +# my $error = Net::SSLeay::get_error( +# POE::Component::SSLify::SSLify_GetSSL($socket), +# POE::Component::SSLify::SSLify_GetStatus($socket) +# ); +# +# # returns: result code, which is one of the following values: +# # 0 - SSL_ERROR_NONE +# # 1 - SSL_ERROR_SSL +# # 2 - SSL_ERROR_WANT_READ +# # 3 - SSL_ERROR_WANT_WRITE +# # 4 - SSL_ERROR_WANT_X509_LOOKUP +# # 5 - SSL_ERROR_SYSCALL +# # 6 - SSL_ERROR_ZERO_RETURN +# # 7 - SSL_ERROR_WANT_CONNECT +# # 8 - SSL_ERROR_WANT_ACCEPT +# +# if ($error) { +# $request->connect_error('sslify', $error, 'ssl error'); +# return; +# } +# } +# } + + # Catching this in case the SSL code falls through and there's still + # an error. if ($errnum) { if ($operation eq "connect") { $request->connect_error($operation, $errnum, $errstr);


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.