Skip to content

Send correct requests & responses #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions access_log_variables.t
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ my $bytes_sent = length http_get('/bytes');
# pipelined requests

http(<<EOF);
GET /pipe HTTP/1.1
Host: localhost

GET /pipe HTTP/1.1
Host: localhost
Connection: close

GET /pipe HTTP/1.1\r
Host: localhost\r
\r
GET /pipe HTTP/1.1\r
Host: localhost\r
Connection: close\r
\r
EOF

$t->stop();
Expand All @@ -116,7 +116,7 @@ $log = $t->read_file('msec.log');
like($log, qr!/msec [\d\.]+!, 'msec');

$log = $t->read_file('request.log');
like($log, qr!/request 200 39 [\d\.]+!, 'request');
like($log, qr!/request 200 42 [\d\.]+!, 'request');

$log = $t->read_file('bytes.log');
is($log, "/bytes $bytes_sent 2\n", 'bytes sent');
Expand Down
8 changes: 4 additions & 4 deletions auth_basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ sub http_get_auth {
my $auth = encode_base64($user . ':' . $password, '');

return http(<<EOF);
GET $url HTTP/1.0
Host: localhost
Authorization: Basic $auth

GET $url HTTP/1.0\r
Host: localhost\r
Authorization: Basic $auth\r
\r
EOF
}

Expand Down
8 changes: 4 additions & 4 deletions auth_delay.t
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ sub http_get_auth {
my $auth = encode_base64($user . ':' . $password, '');

return http(<<EOF);
GET $url HTTP/1.0
Host: localhost
Authorization: Basic $auth

GET $url HTTP/1.0\r
Host: localhost\r
Authorization: Basic $auth\r
\r
EOF
}

Expand Down
12 changes: 6 additions & 6 deletions auth_request.t
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ SKIP: {
sub http_get_auth {
my ($url, %extra) = @_;
return http(<<EOF, %extra);
GET $url HTTP/1.0
Host: localhost
Authorization: Basic dXNlcjpzZWNyZXQ=

GET $url HTTP/1.0\r
Host: localhost\r
Authorization: Basic dXNlcjpzZWNyZXQ=\r
\r
EOF
}

Expand Down Expand Up @@ -268,8 +268,8 @@ sub fastcgi_daemon {

while ($request->Accept() >= 0) {
print <<EOF;
Content-Type: text/html

Content-Type: text/html\r
\r
INVISIBLE
EOF
}
Expand Down
196 changes: 98 additions & 98 deletions dav.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,46 +61,46 @@ $t->run();
my $r;

$r = http(<<EOF . '0123456789');
PUT /file HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

PUT /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put file');
is(-s $t->testdir() . '/file', 10, 'put file size');

$r = http(<<EOF);
PUT /file HTTP/1.1
Host: localhost
Connection: close
Content-Length: 0

PUT /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 0\r
\r
EOF

like($r, qr/204 No Content/, 'put file again');
unlike($r, qr/Content-Length|Transfer-Encoding/, 'no length in 204');
is(-s $t->testdir() . '/file', 0, 'put file again size');

$r = http(<<EOF);
DELETE /file HTTP/1.1
Host: localhost
Connection: close
Content-Length: 0

DELETE /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 0\r
\r
EOF

like($r, qr/204 No Content/, 'delete file');
unlike($r, qr/Content-Length|Transfer-Encoding/, 'no length in 204');
ok(!-f $t->testdir() . '/file', 'file deleted');

$r = http(<<EOF . '0123456789' . 'extra');
PUT /file HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

PUT /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms,
Expand All @@ -109,22 +109,22 @@ is(-s $t->testdir() . '/file', 10,
'put file extra data size');

$r = http(<<EOF . '0123456789');
PUT /file%20sp HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

PUT /file%20sp HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr!Location: /file%20sp\x0d?$!ms, 'put file escaped');

# 201 replies contain body, response should indicate it's empty

$r = http(<<EOF);
MKCOL /test/ HTTP/1.1
Host: localhost
Connection: close

MKCOL /test/ HTTP/1.1\r
Host: localhost\r
Connection: close\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'mkcol');
Expand All @@ -137,31 +137,31 @@ like($r, qr!(?(?{ $r =~ /Location/ })Location: /test/)!, 'mkcol location');
}

$r = http(<<EOF);
COPY /test/ HTTP/1.1
Host: localhost
Destination: /test-moved/
Connection: close

COPY /test/ HTTP/1.1\r
Host: localhost\r
Destination: /test-moved/\r
Connection: close\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'copy dir');

$r = http(<<EOF);
MOVE /test/ HTTP/1.1
Host: localhost
Destination: /test-moved/
Connection: close

MOVE /test/ HTTP/1.1\r
Host: localhost\r
Destination: /test-moved/\r
Connection: close\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'move dir');

$r = http(<<EOF);
COPY /file HTTP/1.1
Host: localhost
Destination: /file-moved%20escape
Connection: close

COPY /file HTTP/1.1\r
Host: localhost\r
Destination: /file-moved%20escape\r
Connection: close\r
\r
EOF

like($r, qr/204 No Content/, 'copy file escaped');
Expand All @@ -170,22 +170,22 @@ is(-s $t->testdir() . '/file-moved escape', 10, 'file copied unescaped');
$t->write_file('file.exist', join '', (1 .. 42));

$r = http(<<EOF);
COPY /file HTTP/1.1
Host: localhost
Destination: /file.exist
Connection: close

COPY /file HTTP/1.1\r
Host: localhost\r
Destination: /file.exist\r
Connection: close\r
\r
EOF

like($r, qr/204 No Content/, 'copy file overwrite');
is(-s $t->testdir() . '/file.exist', 10, 'target file truncated');

$r = http(<<EOF . '0123456789');
PUT /i/alias HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

PUT /i/alias HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put alias');
Expand All @@ -195,75 +195,75 @@ is(-s $t->testdir() . '/alias', 10, 'put alias size');
# request methods with unsupported request body

$r = http(<<EOF . '0123456789');
MKCOL /test/ HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

MKCOL /test/ HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/415 Unsupported/, 'mkcol body');

$r = http(<<EOF . '0123456789');
COPY /file HTTP/1.1
Host: localhost
Destination: /file.exist
Connection: close
Content-Length: 10

COPY /file HTTP/1.1\r
Host: localhost\r
Destination: /file.exist\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/415 Unsupported/, 'copy body');

$r = http(<<EOF . '0123456789');
DELETE /file HTTP/1.1
Host: localhost
Connection: close
Content-Length: 10

DELETE /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Content-Length: 10\r
\r
EOF

like($r, qr/415 Unsupported/, 'delete body');

$r = http(<<EOF);
MKCOL /test/ HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

a
0123456789
0

MKCOL /test/ HTTP/1.1\r
Host: localhost\r
Connection: close\r
Transfer-Encoding: chunked\r
\r
a\r
0123456789\r
0\r
\r
EOF

like($r, qr/415 Unsupported/, 'mkcol body chunked');

$r = http(<<EOF);
COPY /file HTTP/1.1
Host: localhost
Destination: /file.exist
Connection: close
Transfer-Encoding: chunked

a
0123456789
0

COPY /file HTTP/1.1\r
Host: localhost\r
Destination: /file.exist\r
Connection: close\r
Transfer-Encoding: chunked\r
\r
a\r
0123456789\r
0\r
\r
EOF

like($r, qr/415 Unsupported/, 'copy body chunked');

$r = http(<<EOF);
DELETE /file HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

a
0123456789
0

DELETE /file HTTP/1.1\r
Host: localhost\r
Connection: close\r
Transfer-Encoding: chunked\r
\r
a\r
0123456789\r
0\r
\r
EOF

like($r, qr/415 Unsupported/, 'delete body chunked');
Expand Down
Loading