Skip to content

Commit

Permalink
improved IIS and WebSphere compatibility of Mojo::Message::Request (c…
Browse files Browse the repository at this point in the history
…loses #564)
  • Loading branch information
kraih committed Nov 14, 2013
1 parent 56f8ff1 commit 18a5596
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

4.58 2013-11-13
4.58 2013-11-14
- Improved IIS and WebSphere compatibility of Mojo::Message::Request.

4.57 2013-11-11
- Improved compatibility with IO::Socket::SSL 1.957.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Message/Request.pm
Expand Up @@ -235,7 +235,7 @@ sub _parse_env {
}

# HTTPS
$base->scheme('https') if $env->{HTTPS};
$base->scheme('https') if uc($env->{HTTPS} // '') eq 'ON';

# Path
my $path = $url->path->parse($env->{PATH_INFO} ? $env->{PATH_INFO} : '');
Expand Down
27 changes: 25 additions & 2 deletions t/mojo/request_cgi.t
Expand Up @@ -294,7 +294,7 @@ is_deeply $req->param('hello'), 'world', 'right parameters';
is $req->url->to_abs->to_string, 'http://127.0.0.1:13028/upload',
'right absolute URL';

# Parse Apache 2.2.11 CGI environment variables and body (HTTPS)
# Parse Apache 2.2.11 CGI environment variables and body (HTTPS=ON)
$req = Mojo::Message::Request->new;
$req->parse(
CONTENT_LENGTH => 11,
Expand All @@ -304,7 +304,7 @@ $req->parse(
REQUEST_METHOD => 'GET',
SCRIPT_NAME => '/test/index.cgi',
HTTP_HOST => 'localhost',
HTTPS => 'on',
HTTPS => 'ON',
SERVER_PROTOCOL => 'HTTP/1.0'
);
$req->parse('hello=world');
Expand Down Expand Up @@ -463,4 +463,27 @@ my $file = $req->upload('file');
is $file->filename, 'file.txt', 'right filename';
is $file->slurp, '11023456789', 'right uploaded content';

# Parse IIS 7.5 like CGI environment (HTTPS=off)
$req = Mojo::Message::Request->new;
$req->parse(
CONTENT_LENGTH => 0,
PATH_INFO => '/index.pl/',
SERVER_SOFTWARE => 'Microsoft-IIS/7.5',
QUERY_STRING => '',
REQUEST_METHOD => 'GET',
SCRIPT_NAME => '/index.pl',
HTTP_HOST => 'test',
HTTPS => 'off',
SERVER_PROTOCOL => 'HTTP/1.1'
);
ok $req->is_finished, 'request is finished';
is $req->method, 'GET', 'right method';
is $req->url->path, '', 'right URL';
is $req->url->base->protocol, 'http', 'right base protocol';
is $req->url->base->path, '/index.pl/', 'right base path';
is $req->url->base->host, 'test', 'right base host';
ok !$req->url->query->to_string, 'no query';
is $req->version, '1.1', 'right version';
ok !$req->is_secure, 'not secure';

done_testing();

0 comments on commit 18a5596

Please sign in to comment.