… | |
… | |
936 | # also, the UA should ask the user for 301 and 307 and POST, |
936 | # also, the UA should ask the user for 301 and 307 and POST, |
937 | # industry standard seems to be to simply follow. |
937 | # industry standard seems to be to simply follow. |
938 | # we go with the industry standard. 308 is defined |
938 | # we go with the industry standard. 308 is defined |
939 | # by rfc7538 |
939 | # by rfc7538 |
940 | if ($status == 301 or $status == 302 or $status == 303) { |
940 | if ($status == 301 or $status == 302 or $status == 303) { |
|
|
941 | $redirect = 1; |
941 | # HTTP/1.1 is unclear on how to mutate the method |
942 | # HTTP/1.1 is unclear on how to mutate the method |
942 | $method = "GET" unless $method eq "HEAD"; |
943 | unless ($method eq "HEAD") { |
943 | $redirect = 1; |
944 | $method = "GET"; |
|
|
945 | delete $arg{body}; |
|
|
946 | } |
944 | } elsif ($status == 307 or $status == 308) { |
947 | } elsif ($status == 307 or $status == 308) { |
945 | $redirect = 1; |
948 | $redirect = 1; |
946 | } |
949 | } |
947 | } |
950 | } |
948 | |
951 | |
… | |
… | |
1176 | |
1179 | |
1177 | # now handle proxy-CONNECT method |
1180 | # now handle proxy-CONNECT method |
1178 | if ($proxy && $uscheme eq "https") { |
1181 | if ($proxy && $uscheme eq "https") { |
1179 | # oh dear, we have to wrap it into a connect request |
1182 | # oh dear, we have to wrap it into a connect request |
1180 | |
1183 | |
|
|
1184 | my $auth = exists $hdr{"proxy-authorization"} |
|
|
1185 | ? "proxy-authorization: " . (delete $hdr{"proxy-authorization"}) . "\015\012" |
|
|
1186 | : ""; |
|
|
1187 | |
1181 | # maybe re-use $uauthority with patched port? |
1188 | # maybe re-use $uauthority with patched port? |
1182 | $state{handle}->push_write ("CONNECT $uhost:$uport HTTP/1.0\015\012\015\012"); |
1189 | $state{handle}->push_write ("CONNECT $uhost:$uport HTTP/1.0\015\012$auth\015\012"); |
1183 | $state{handle}->push_read (line => $qr_nlnl, sub { |
1190 | $state{handle}->push_read (line => $qr_nlnl, sub { |
1184 | $_[1] =~ /^HTTP\/([0-9\.]+) \s+ ([0-9]{3}) (?: \s+ ([^\015\012]*) )?/ix |
1191 | $_[1] =~ /^HTTP\/([0-9\.]+) \s+ ([0-9]{3}) (?: \s+ ([^\015\012]*) )?/ix |
1185 | or return _error %state, $cb, { @pseudo, Status => 599, Reason => "Invalid proxy connect response ($_[1])" }; |
1192 | or return _error %state, $cb, { @pseudo, Status => 599, Reason => "Invalid proxy connect response ($_[1])" }; |
1186 | |
1193 | |
1187 | if ($2 == 200) { |
1194 | if ($2 == 200) { |
… | |
… | |
1190 | } else { |
1197 | } else { |
1191 | _error %state, $cb, { @pseudo, Status => $2, Reason => $3 }; |
1198 | _error %state, $cb, { @pseudo, Status => $2, Reason => $3 }; |
1192 | } |
1199 | } |
1193 | }); |
1200 | }); |
1194 | } else { |
1201 | } else { |
|
|
1202 | delete $hdr{"proxy-authorization"} unless $proxy; |
|
|
1203 | |
1195 | $handle_actual_request->(); |
1204 | $handle_actual_request->(); |
1196 | } |
1205 | } |
1197 | }; |
1206 | }; |
1198 | |
1207 | |
1199 | _get_slot $uhost, sub { |
1208 | _get_slot $uhost, sub { |