Skip Menu |

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

Report information
The Basics
Id: 127613
Status: open
Priority: 0/
Queue: Net-Async-HTTP

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

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



Subject: Path-only redirects cause non-path changes in URLs
Redirects which give a path only cause HTTPS URLs to be rewritten as HTTP URLs with port 443. For instance, https://stackoverflow.com/a/8277028 which has Location: /questions/8276983/why-cant-i-use-the-method-cmp-in-python-3-as-for-python-2/8277028#8277028 generates a redirect to http://stackoverflow.com:443/questions/8276983/why-cant-i-use-the-method-cmp-in-python-3-as-for-python-2/8277028#8277028
I seem unable to reproduce this at the moment (against v0.42). Attached unit-test already passes. Specifically note lines 38 and 72. -- Paul Evans
Subject: 91rt127613.t
#!/usr/bin/perl use strict; use warnings; use Test::More; use IO::Async::Test; use IO::Async::Loop; use Net::Async::HTTP; my $CRLF = "\x0d\x0a"; # because \r\n isn't portable my $loop = IO::Async::Loop->new(); testing_loop( $loop ); my $http = Net::Async::HTTP->new( user_agent => "", # Don't put one in request headers ); $loop->add( $http ); # path-only redirects respect SSL { my $redir_response; my $location; my $response; my $peersock; no warnings 'redefine'; local *IO::Async::Handle::connect = sub { my $self = shift; my %args = @_; $args{host} eq "host0" or die "Expected $args{host} eq host0"; $args{service} eq "443" or die "Expected $args{service} eq 443"; $args{extensions} and $args{extensions}[0] eq "SSL" or die "Expected 'SSL' extension"; ( my $selfsock, $peersock ) = IO::Async::OS->socketpair() or die "Cannot create socket pair - $!"; $self->set_handle( $selfsock ); return Future->new->done( $self ); }; my $future = $http->do_request( uri => URI->new( "https://host0/doc" ), timeout => 10, on_response => sub { $response = $_[0] }, on_redirect => sub { ( $redir_response, $location ) = @_ }, on_error => sub { die "Test died early - $_[0]" }, ); my $request_stream = ""; wait_for_stream { $request_stream =~ m/$CRLF$CRLF/ } $peersock => $request_stream; $peersock->syswrite( "HTTP/1.1 301 Moved Permanently$CRLF" . "Content-Length: 0$CRLF" . "Location: /some/other/path$CRLF" . "Connection: Keep-Alive$CRLF" . "$CRLF" ); $request_stream = ""; wait_for_stream { $request_stream =~ m/$CRLF$CRLF/ } $peersock => $request_stream; $request_stream =~ s/^(.*)$CRLF//; my $req_firstline = $1; is( $req_firstline, "GET /some/other/path HTTP/1.1", 'First line for redirected request' ); $peersock->syswrite( "HTTP/1.1 200 OK$CRLF" . "Content-Length: 8$CRLF". "Content-Type: text/plain$CRLF" . "Connection: Keep-Alive$CRLF" . "$CRLF" . "Document" ); wait_for { defined $response }; is( $response->content_type, "text/plain", 'Content type of final response' ); is( $response->content, "Document", 'Content of final response' ); } done_testing;
On Wed Nov 14 17:05:00 2018, PEVANS wrote: Show quoted text
> I seem unable to reproduce this at the moment (against v0.42).
Check $response->base, since that's where my redirect URIs are coming from.