Skip to content

Commit

Permalink
fixed support for RFC 2817 in Mojo::Message::Request (closes #468)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 17, 2013
1 parent 2eaf19c commit 99dff6e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

3.91 2013-03-17
- Improved tests.
- Fixed support for RFC 2817 in Mojo::Message::Request.
- Fixed whitespace bug in Mojo::DOM::HTML.

3.90 2013-03-14
Expand Down
7 changes: 2 additions & 5 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -79,11 +79,8 @@ sub fix_headers {
$headers->authorization('Basic ' . b64_encode($auth, ''))
if $auth && !$headers->authorization;

# Proxy
# Basic proxy authentication
if (my $proxy = $self->proxy) {
$url = $proxy if $self->method eq 'CONNECT';

# Basic proxy authentication
my $proxy_auth = $proxy->userinfo;
$headers->proxy_authorization('Basic ' . b64_encode($proxy_auth, ''))
if $proxy_auth && !$headers->proxy_authorization;
Expand Down Expand Up @@ -291,7 +288,7 @@ Mojo::Message::Request - HTTP request
=head1 DESCRIPTION
L<Mojo::Message::Request> is a container for HTTP requests as described in RFC
2616.
2616 and RFC 2817.
=head1 EVENTS
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/request.t
Expand Up @@ -985,7 +985,7 @@ is $req->proxy->userinfo, 'Aladdin:open sesame', 'right proxy userinfo';
# Parse full HTTP 1.1 proxy connect request with basic authentication
$req = Mojo::Message::Request->new;
$req->parse("CONNECT 127.0.0.1:3000 HTTP/1.1\x0d\x0a");
$req->parse("Host: 127.0.0.1\x0d\x0a");
$req->parse("Host: 127.0.0.1:3000\x0d\x0a");
$req->parse("Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\x0d\x0a");
$req->parse("Content-Length: 0\x0d\x0a\x0d\x0a");
ok $req->is_finished, 'request is finished';
Expand Down Expand Up @@ -1423,7 +1423,7 @@ is $req->url->to_abs, 'http://127.0.0.1:3000', 'right absolute URL';
is $req->proxy->userinfo, 'Aladdin:open sesame', 'right proxy userinfo';
is $req->headers->authorization, 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
'right "Authorization" value';
is $req->headers->host, '127.0.0.2:8080', 'right "Host" value';
is $req->headers->host, '127.0.0.1:3000', 'right "Host" value';
is $req->headers->proxy_authorization, 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
'right "Proxy-Authorization" value';

Expand Down
2 changes: 1 addition & 1 deletion t/mojo/transactor.t
Expand Up @@ -434,7 +434,7 @@ $tx->req->fix_headers;
ok !$tx->req->headers->authorization, 'no "Authorization" header';
is $tx->req->headers->proxy_authorization, 'Basic c3JpOnNlY3IzdA==',
'right "Proxy-Authorization" header';
is $tx->req->headers->host, '127.0.0.1:3000', 'right "Host" header';
is $tx->req->headers->host, 'mojolicio.us', 'right "Host" header';
is $t->proxy_connect($tx), undef, 'already a CONNECT request';

# Simple 302 redirect
Expand Down

0 comments on commit 99dff6e

Please sign in to comment.