summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/t/http11
diff options
context:
space:
mode:
Diffstat (limited to 'debian/perl-framework/t/http11')
-rw-r--r--debian/perl-framework/t/http11/all.t10
-rw-r--r--debian/perl-framework/t/http11/basicauth.t32
-rw-r--r--debian/perl-framework/t/http11/chunked.t133
-rw-r--r--debian/perl-framework/t/http11/chunked2.t18
-rw-r--r--debian/perl-framework/t/http11/clength.t27
-rw-r--r--debian/perl-framework/t/http11/post.t17
6 files changed, 237 insertions, 0 deletions
diff --git a/debian/perl-framework/t/http11/all.t b/debian/perl-framework/t/http11/all.t
new file mode 100644
index 0000000..549cf64
--- /dev/null
+++ b/debian/perl-framework/t/http11/all.t
@@ -0,0 +1,10 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::TestRequest;
+use Apache::Test;
+
+#skip all tests in this directory unless we have client http/1.1 support
+plan tests => 1, \&need_http11;
+
+ok 1;
diff --git a/debian/perl-framework/t/http11/basicauth.t b/debian/perl-framework/t/http11/basicauth.t
new file mode 100644
index 0000000..1bd91dc
--- /dev/null
+++ b/debian/perl-framework/t/http11/basicauth.t
@@ -0,0 +1,32 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+
+#test basic auth with keepalives
+
+Apache::TestRequest::user_agent(keep_alive => 1);
+
+Apache::TestRequest::scheme('http')
+ unless have_module 'LWP::Protocol::https10'; #lwp 5.60
+
+plan tests => 3, need_module 'authany';
+
+my $url = '/authany/index.html';
+
+my $res = GET $url;
+
+ok $res->code == 401;
+
+$res = GET $url, username => 'guest', password => 'guest';
+
+ok $res->code == 200;
+
+my $request_num = Apache::TestRequest::user_agent_request_num($res);
+
+ok $request_num == 3; #1 => no credentials
+ #2 => 401 response with second request
+ #3 => 200 with guest/guest credentials
+
+
diff --git a/debian/perl-framework/t/http11/chunked.t b/debian/perl-framework/t/http11/chunked.t
new file mode 100644
index 0000000..2331239
--- /dev/null
+++ b/debian/perl-framework/t/http11/chunked.t
@@ -0,0 +1,133 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+Apache::TestRequest::user_agent(keep_alive => 1);
+
+Apache::TestRequest::scheme('http')
+ unless have_module 'LWP::Protocol::https10'; #lwp 5.60
+
+#In httpd-2.0, chunked encoding is optional and will only be used
+#if response is > 4*AP_MIN_BYTES_TO_WRITE (see server/protocol.c)
+
+my @small_sizes = (100, 5000);
+my @chunk_sizes = (25432, 75962, 100_000, 300_000);
+
+my $tests = (@chunk_sizes + @small_sizes) * 5;
+
+if (! have_module 'random_chunk') {
+ print "# Skipping; missing prerequisite module 'random_chunk'\n";
+}
+plan tests => $tests, need_module 'random_chunk';
+
+my $location = '/random_chunk';
+my $requests = 0;
+
+sub expect_chunked {
+ my $size = shift;
+ sok sub {
+ my $res = GET "/random_chunk?0,$size";
+ my $body = $res->content;
+ my $length = 0;
+
+ if ($body =~ s/__END__:(\d+)$//) {
+ $length = $1;
+ }
+
+ ok t_cmp($res->protocol,
+ "HTTP/1.1",
+ "response protocol"
+ );
+
+ my $enc = $res->header('Transfer-Encoding') ||
+ $res->header('Client-Transfer-Encoding') || #lwp 5.61+
+ '';
+ my $ct = $res->header('Content-Length') || 0;
+
+ ok t_cmp($enc,
+ "chunked",
+ "response Transfer-Encoding"
+ );
+
+ ok t_cmp($ct,
+ 0,
+ "no Content-Length"
+ );
+
+ ok t_cmp(length($body),
+ $length,
+ "body length"
+ );
+
+ $requests++;
+ my $request_num =
+ Apache::TestRequest::user_agent_request_num($res);
+
+ return t_cmp($request_num,
+ $requests,
+ "number of requests"
+ );
+ }, 5;
+}
+
+sub expect_not_chunked {
+ my $size = shift;
+ sok sub {
+ my $res = GET "/random_chunk?0,$size";
+ my $body = $res->content;
+ my $content_length = length $res->content;
+ my $length = 0;
+
+ if ($body =~ s/__END__:(\d+)$//) {
+ $length = $1;
+ }
+
+ ok t_cmp($res->protocol,
+ "HTTP/1.1",
+ "response protocol"
+ );
+
+ my $enc = $res->header('Transfer-Encoding') || '';
+ my $ct = $res->header('Content-Length') || '';
+
+ ok !t_cmp($enc,
+ "chunked",
+ "no Transfer-Encoding (test result inverted)"
+ );
+
+ ok t_cmp($ct,
+ (($ct eq '') ? $ct : $content_length),
+ "content length"
+ );
+
+ ok t_cmp(length($body),
+ $length,
+ "body length"
+ );
+
+ $requests++;
+ my $request_num =
+ Apache::TestRequest::user_agent_request_num($res);
+
+ return t_cmp($request_num,
+ $requests,
+ "number of requests"
+ );
+ }, 5;
+}
+
+for my $size (@chunk_sizes) {
+ expect_chunked $size;
+}
+
+for my $size (@small_sizes) {
+ if (have_apache 1) {
+ expect_chunked $size;
+ }
+ else {
+ expect_not_chunked $size;
+ }
+}
diff --git a/debian/perl-framework/t/http11/chunked2.t b/debian/perl-framework/t/http11/chunked2.t
new file mode 100644
index 0000000..02ec212
--- /dev/null
+++ b/debian/perl-framework/t/http11/chunked2.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+plan tests => 2, need 'bucketeer';
+
+Apache::TestRequest::user_agent(keep_alive => 1);
+
+# Regression test for ap_http_chunk_filter bug.
+
+my $r = GET("/apache/chunked/flush.html");
+
+ok t_cmp($r->code, 200, "successful response");
+
+ok t_cmp($r->content, "aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb");
diff --git a/debian/perl-framework/t/http11/clength.t b/debian/perl-framework/t/http11/clength.t
new file mode 100644
index 0000000..14254f8
--- /dev/null
+++ b/debian/perl-framework/t/http11/clength.t
@@ -0,0 +1,27 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+my %tests = (
+ "/foobar.html" => "foobar",
+ # flushheap0 inserts a single FLUSH bucket after the content, before EOS
+ "/apache/chunked/flushheap0.html" => "bbbbbbbbbb",
+ );
+
+plan tests => 3*scalar keys %tests, need 'bucketeer';
+
+Apache::TestRequest::user_agent(keep_alive => 1);
+
+foreach my $path (sort keys %tests) {
+ my $expected = $tests{$path};
+ my $r = GET($path);
+
+ ok t_cmp($r->code, 200, "successful response");
+
+ ok t_cmp($r->header("Content-Length"), length $expected);
+
+ ok t_cmp($r->content, $expected);
+}
diff --git a/debian/perl-framework/t/http11/post.t b/debian/perl-framework/t/http11/post.t
new file mode 100644
index 0000000..3610e5c
--- /dev/null
+++ b/debian/perl-framework/t/http11/post.t
@@ -0,0 +1,17 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestCommon ();
+
+local $ENV{APACHE_TEST_HTTP11} = 1;
+
+#same as t/apache/post but turn on HTTP/1.1
+Apache::TestRequest::user_agent(keep_alive => 1);
+
+my $module = 'eat_post';
+my $num = Apache::TestCommon::run_post_test_sizes();
+
+plan tests => $num, [$module];
+
+Apache::TestCommon::run_post_test($module);