Skip Menu |

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

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

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

Bug Information
Severity: Important
Broken in: 0.13
Fixed in: 0.14



Subject: on_response HTTP::Response objects lack redirection information
Hi, Recently I've discovered that Net::Async::HTTP doesn't properly fill in redirections in HTTP::Response objects in on_response functions. For instance, http://goo.gl/mR2d should give me two redirect response objects when I call $response->redirects; presently it yields zero. Thanks, Kiyoshi Aman
On Mon Nov 28 19:25:12 2011, AERDAN wrote: Show quoted text
> instance, http://goo.gl/mR2d should give me two redirect response
This short link doesn't appear to go anywhere. Can you supply another one, or preferably just attach source in a .pl file on this ticket? -- Paul Evans
On Tue Nov 29 03:35:46 2011, PEVANS wrote: Show quoted text
> On Mon Nov 28 19:25:12 2011, AERDAN wrote:
> > instance, http://goo.gl/mR2d should give me two redirect response
> > This short link doesn't appear to go anywhere.
But it does go somewhere, see attached wget output.
Subject: wget.txt
aphrael@inari:~$ wget http://goo.gl/mR2d --2011-11-29 05:09:24-- http://goo.gl/mR2d Resolving goo.gl... 74.125.225.74, 74.125.225.75, 74.125.225.76, ... Connecting to goo.gl|74.125.225.74|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://google.com/ [following] --2011-11-29 05:09:24-- http://google.com/ Resolving google.com... 74.125.225.82, 74.125.225.83, 74.125.225.84, ... Connecting to google.com|74.125.225.82|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://www.google.com/ [following] --2011-11-29 05:09:24-- http://www.google.com/ Resolving www.google.com... 74.125.225.49, 74.125.225.50, 74.125.225.51, ... Connecting to www.google.com|74.125.225.49|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: `mR2d' [ <=> ] 10,692 --.-K/s in 0.001s 2011-11-29 05:09:24 (11.4 MB/s) - `mR2d' saved [10692]
Debug redirect-probing script: http://inari.aerdan.org/debug-redirect.pl It *should* print redirections. Presently, it does not.
FTR; script attached.
Subject: debug-redirect.pl
#!/usr/bin/perl use strict; use warnings; use feature 'say'; use URI; use IO::Async::Loop; use Net::Async::HTTP; my $loop = IO::Async::Loop->new(); my $ua = Net::Async::HTTP->new( loop => $loop ); $ua->do_request( method => "GET", uri => URI->new( $ARGV[0] ), on_response => sub { my ( $response ) = @_; for my $redir ($response->redirects) { say "!! redirection !!"; say $redir->as_string; } say $response->as_string; $loop->loop_stop; }, on_error => sub { my ( $message ) = @_; print STDERR "Failed - $message\n"; $loop->loop_stop; } ); $loop->loop_forever();
Fixed. ----- $ perl -Mblib RT72791-debug-redirect.pl http://goo.gl/mR2d !! redirection !! HTTP/1.1 301 Moved Permanently Cache-Control: private, max-age=86400 Date: Sun, 11 Dec 2011 21:50:46 GMT Transfer-Encoding: chunked Age: 190 Location: http://google.com/ Server: GSE Content-Type: text/html; charset=UTF-8 Expires: Sun, 11 Dec 2011 21:50:46 GMT X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block !! redirection !! HTTP/1.1 301 Moved Permanently Cache-Control: public, max-age=2592000 Date: Sun, 11 Dec 2011 21:53:57 GMT Location: http://www.google.com/ Server: gws Content-Length: 219 Content-Type: text/html; charset=UTF-8 Expires: Tue, 10 Jan 2012 21:53:57 GMT X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block !! redirection !! HTTP/1.1 302 Found Cache-Control: private Date: Sun, 11 Dec 2011 21:53:57 GMT Location: http://www.google.co.uk/ Server: gws Content-Length: 221 Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=683e81a92f694b42:FF=0:TM=1323640437:LM=1323640437:S=oTZ4yA6wnM9OQeA-; expires=Tue, 10-Dec-2013 21:53:57 GMT; path=/; domain=.google.com X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block HTTP/1.1 200 OK Cache-Control: private, max-age=0 Date: Sun, 11 Dec 2011 21:53:57 GMT Transfer-Encoding: chunked Server: gws Content-Type: text/html; charset=ISO-8859-1 Expires: -1 ... -- Paul Evans
Subject: rt72791.patch
This was fixed in 0.14. -- Paul Evans