Skip to content

Commit

Permalink
fixed small content encoding bug in Mojo::Message
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 13, 2012
1 parent ddffb32 commit e6634f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Changes
@@ -1,4 +1,8 @@

3.30 2012-08-14
- Added te method to Mojo::Headers.
- Fixed small content encoding bug in Mojo::Message.

3.29 2012-08-13
- Improved documentation.
- Improved tests.
Expand Down
25 changes: 12 additions & 13 deletions lib/Mojo/Headers.pm
Expand Up @@ -9,12 +9,11 @@ has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 10240 };
my @HEADERS = (
qw(Accept Accept-Language Accept-Ranges Authorization Connection),
qw(Cache-Control Content-Disposition Content-Length Content-Range),
qw(Content-Transfer-Encoding Content-Type Cookie DNT Date ETag Expect),
qw(Expires Host If-Modified-Since Last-Modified Location),
qw(Proxy-Authenticate Proxy-Authorization Range Sec-WebSocket-Accept),
qw(Sec-WebSocket-Key Sec-WebSocket-Origin Sec-WebSocket-Protocol),
qw(Sec-WebSocket-Version Server Set-Cookie Status Trailer),
qw(Transfer-Encoding Upgrade User-Agent WWW-Authenticate)
qw(Content-Type Cookie DNT Date ETag Expect Expires Host If-Modified-Since),
qw(Last-Modified Location Proxy-Authenticate Proxy-Authorization Range),
qw(Sec-WebSocket-Accept Sec-WebSocket-Key Sec-WebSocket-Origin),
qw(Sec-WebSocket-Protocol Sec-WebSocket-Version Server Set-Cookie Status),
qw(TE Trailer Transfer-Encoding Upgrade User-Agent WWW-Authenticate)
);
{
no strict 'refs';
Expand Down Expand Up @@ -289,13 +288,6 @@ Shortcut for the C<Content-Length> header.
Shortcut for the C<Content-Range> header.
=head2 C<content_transfer_encoding>
my $encoding = $headers->content_transfer_encoding;
$headers = $headers->content_transfer_encoding('foo');
Shortcut for the C<Content-Transfer-Encoding> header.
=head2 C<content_type>
my $content_type = $headers->content_type;
Expand Down Expand Up @@ -517,6 +509,13 @@ Shortcut for the C<Set-Cookie> header.
Shortcut for the C<Status> header.
=head2 C<te>
my $te = $headers->te;
$headers = $headers->te('chunked');
Shortcut for the C<TE> header.
=head2 C<to_hash>
my $single = $headers->to_hash;
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Message.pm
Expand Up @@ -370,8 +370,7 @@ sub _parse_formdata {
# Form value
unless (defined $filename) {
$value = $part->asset->slurp;
$value = decode($charset, $value) // $value
if $charset && !$part->headers->content_transfer_encoding;
$value = decode($charset, $value) // $value if $charset;
}

push @formdata, [$name, $filename, $value];
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -38,7 +38,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.29';
our $VERSION = '3.30';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
7 changes: 3 additions & 4 deletions t/mojo/headers.t
Expand Up @@ -57,10 +57,8 @@ is $headers->connection('foo')->connection, 'foo', 'right value';
is $headers->cache_control('foo')->cache_control, 'foo', 'right value';
is $headers->content_disposition('foo')->content_disposition, 'foo',
'right value';
is $headers->content_length('foo')->content_length, 'foo', 'right value';
is $headers->content_range('foo')->content_range, 'foo', 'right value';
is $headers->content_transfer_encoding('foo')->content_transfer_encoding,
'foo', 'right value';
is $headers->content_length('foo')->content_length, 'foo', 'right value';
is $headers->content_range('foo')->content_range, 'foo', 'right value';
is $headers->content_type('foo')->content_type, 'foo', 'right value';
is $headers->cookie('foo')->cookie, 'foo', 'right value';
is $headers->dnt('foo')->dnt, 'foo', 'right value';
Expand Down Expand Up @@ -89,6 +87,7 @@ is $headers->sec_websocket_version('foo')->sec_websocket_version, 'foo',
is $headers->server('foo')->server, 'foo', 'right value';
is $headers->set_cookie('foo')->set_cookie, 'foo', 'right value';
is $headers->status('foo')->status, 'foo', 'right value';
is $headers->te('foo')->te, 'foo', 'right value';
is $headers->trailer('foo')->trailer, 'foo', 'right value';
is $headers->transfer_encoding('foo')->transfer_encoding, 'foo', 'right value';
is $headers->upgrade('foo')->upgrade, 'foo', 'right value';
Expand Down

0 comments on commit e6634f3

Please sign in to comment.