Subject: | %I wrong on uploads of multipart |
The following test illustrates quite well that the value for %I of "11" is way less than the actual amout of bytes we are sending to the server.
% MOJO_DAEMON_DEBUG=1 perl -Mblib -e '
package MyApp;
our $LOG;
use Mojo::Base "Mojolicious";
sub startup {
my $self = shift;
$self->plugin(AccessLog => { format => "%I",
log => sub { $LOG = shift } });
$self->routes->post("/upload")->to("foo#upload");
}
package MyApp::Controller::Foo;
use Mojo::Base "Mojolicious::Controller";
sub upload {
my $self = shift;
my $req = $self->req;
$self->render(text => "Hello!");
}
package main;
use Test::More;
use Test::Mojo;
Test::Mojo->new("MyApp")
->post_ok("/upload", "form", {foo => {filename=>"F",content=>"C"}})->status_is(200)->content_is("Hello!");
cmp_ok $LOG, ">", "200", "expecting quite a bit more than 200 bytes";
done_testing;
'
-- Accept (127.0.0.1)
-- Server <<< Client ()
POST /upload HTTP/1.1
Connection: keep-alive
Host: localhost:39347
User-Agent: Mojolicious (Perl)
Accept-Encoding: gzip
Content-Length: 81
Content-Type: multipart/form-data; boundary=ikZTX
--ikZTX
-- Server <<< Client (/upload)
Content-Disposition: form-data; name="foo"; filename="F"
-- Server <<< Client (/upload)
C
-- Server <<< Client (/upload)
--ikZTX--
-- Server >>> Client (http://localhost:39347/upload)
HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Content-Length: 6
Date: Thu, 19 Mar 2015 16:38:57 GMT
Server: Mojolicious (Perl)
Connection: keep-alive
Hello!
ok 1 - POST /upload
ok 2 - 200 OK
ok 3 - exact match for content
not ok 4 - expecting quite a bit more than 200 bytes
# Failed test 'expecting quite a bit more than 200 bytes'
# at -e line 23.
# '11'
# >
# '200'
1..4
# Looks like you failed 1 test of 4.