You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2017/01/06 14:41:39 UTC
svn commit: r1777618 - /httpd/test/framework/trunk/t/apache/http_strict.t
Author: ylavic
Date: Fri Jan 6 14:41:39 2017
New Revision: 1777618
URL: http://svn.apache.org/viewvc?rev=1777618&view=rev
Log:
Test preserved folding with media type "message/http".
Modified:
httpd/test/framework/trunk/t/apache/http_strict.t
Modified: httpd/test/framework/trunk/t/apache/http_strict.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/apache/http_strict.t?rev=1777618&r1=1777617&r2=1777618&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/apache/http_strict.t (original)
+++ httpd/test/framework/trunk/t/apache/http_strict.t Fri Jan 6 14:41:39 2017
@@ -113,7 +113,7 @@ my @test_cases = (
my $test_fold = need_min_apache_fix("2.2.33", "2.4.26", "2.5.0");
-plan tests => scalar(@test_cases) + $test_fold,
+plan tests => scalar(@test_cases) + $test_fold * 3,
# todo => [25, 26],
need_min_apache_version('2.2.32');
@@ -135,12 +135,13 @@ foreach my $t (@test_cases) {
}
if (defined $cond && not $cond) {
- $req = escape($req);
- print "# SKIPPING:\n# $req\n";
+ print "# SKIPPING:\n# ", escape($req), "\n";
skip "Test prerequisites are not met";
next;
}
+ print "# SENDING:\n# ", escape($req), "\n";
+ print "# DECODED: ", escape($decoded), "\n" if $decoded;
my $sock = Apache::TestRequest::vhost_socket("http_strict");
if (!$sock) {
print "# failed to connect\n";
@@ -150,9 +151,6 @@ foreach my $t (@test_cases) {
$sock->print($req);
$sock->shutdown(1);
sleep(0.1);
- $req = escape($req);
- print "# SENDING:\n# $req\n";
- print "# DECODED: " . escape($decoded) . "\n" if $decoded;
my $response_data = "";
my $buf;
@@ -162,9 +160,7 @@ foreach my $t (@test_cases) {
my $response = HTTP::Response->parse($response_data);
if ($decoded) {
$response_data =~ s/<title>.*/.../s;
- my $out = escape($response_data);
- $out =~ s{\\n}{\\n\n# }g;
- print "# RESPONSE:\n# $out\n";
+ print "# RESPONSE:\n# ", output($response_data), "\n";
}
if (! defined $response) {
die "HTTP::Response->parse failed";
@@ -198,11 +194,33 @@ foreach my $t (@test_cases) {
if ($test_fold) {
my $resp;
my $foo;
+
$resp = GET("/fold");
- $foo = $resp->header("Foo");
ok ($resp->code == 200);
- if(defined($foo)) {
- ok ($foo =~ /Bar Baz/);
+ $foo = $resp->header("Foo");
+ ok (defined($foo) && ($foo =~ /Bar Baz/));
+
+ my $sock = Apache::TestRequest::vhost_socket("http_strict");
+ if ($sock) {
+ my $buf;
+
+ $buf = "GET /fold?message/http HTTP/1.0\r\n\r\n";
+ print "# SENDING:\n# ", escape($buf), "\n";
+ $sock->print($buf);
+ $sock->shutdown(1);
+ sleep(0.1);
+
+ $resp = "";
+ while ($sock->read($buf, 10000) > 0) {
+ $resp .= $buf;
+ }
+ my $re = "\nFoo: Bar\r\n Baz\r\n";
+ print "# expecting /", escape($re), "/, got:\n# ", output($resp), "\n";
+ ok ($resp =~ /$re/);
+ }
+ else {
+ print "# failed to connect\n";
+ ok(0);
}
}
@@ -216,3 +234,10 @@ sub escape
$in =~ s{([\x00-\x1f])}{sprintf("\\x%02x", ord($1))}ge;
return $in;
}
+
+sub output
+{
+ my $in = escape(shift);
+ $in =~ s{\\n}{\\n\n# }g;
+ return $in;
+}