Skip Menu |

This queue is for tickets about the Net-Async-HTTP CPAN distribution.

Report information
The Basics
Id: 93231
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP

People
Owner: Nobody in particular
Requestors: frioux [...] gmail.com
Cc: wes [...] mitsi.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.36



CC: wes [...] mitsi.com
Subject: Does not handle responses with no headers at all
Background: we have some hardware with builtin webservers. Unsurprisingly the webservers are hardly webservers at all. When we do requests they respond with *just* the body. You can see in the included pcap trace. LWP seems to handle it well enough, so I suspect there's no technical reason not to support it in Net::Async::HTTP. Thanks!
Subject: netburner-http.pcapng
Download netburner-http.pcapng
application/octet-stream 1.8k

Message body not shown because it is not plain text.

On Fri Feb 21 12:48:37 2014, frew wrote: Show quoted text
> Background: we have some hardware with builtin webservers. > Unsurprisingly the webservers are hardly webservers at all. When we > do requests they respond with *just* the body. You can see in the > included pcap trace. > > LWP seems to handle it well enough, so I suspect there's no technical > reason not to support it in Net::Async::HTTP.
So, having re-read this again and looked at the pcapng trace, I see that it's not just that an HTTP response has no headers, it's that it doesn't have the HTTP status line /either/, and such isn't really an HTTP response at all. I'm tempted to just say "this is a protocol error and so NaHTTP should reject it". Admittedly the current error is Connection closed while awaiting header Possibly it should check that it gets something looking like m/^HTTP/ because if not that's definitely an error, and reject it at that point. -- Paul Evans
Updated to give a nicer error in these cases. -- Paul Evans
Subject: rt93231.patch
=== modified file 'lib/Net/Async/HTTP/Connection.pm' --- lib/Net/Async/HTTP/Connection.pm 2014-03-27 18:29:41 +0000 +++ lib/Net/Async/HTTP/Connection.pm 2014-10-14 11:01:00 +0000 @@ -268,6 +268,12 @@ $stall_timer->reset; } + if( length $$buffref >= 4 and $$buffref !~ m/^HTTP/ ) { + $self->debug_printf( "ERROR fail" ); + $f->fail( "Did no receive HTTP response from server", http => undef, $req ) unless $f->is_cancelled; + $self->close_now; + } + unless( $$buffref =~ s/^(.*?$CRLF$CRLF)//s ) { if( $closed ) { $self->debug_printf( "ERROR closed" ); === modified file 't/01request.t' --- t/01request.t 2014-03-28 16:36:37 +0000 +++ t/01request.t 2014-10-14 11:01:00 +0000 @@ -520,4 +520,20 @@ expect_res_code => 200, ); +$req = HTTP::Request->new( GET => "/", [ Host => "myhost" ] ); + +do_test_req( "Non-HTTP response", + req => $req, + host => "myhost", + + expect_req_firstline => "GET / HTTP/1.1", + expect_req_headers => { + Host => "myhost", + }, + + response => "Some other protocol, sorry\n", + + expect_error => 1, +); + done_testing;
Released -- Paul Evans