changeset 442:cc4697d6bd16

Tests: added SPDY tests for header field with multiple values.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 24 Jul 2014 21:57:24 +0400
parents cd61bacbbfe0
children d1c4b0d15484
files spdy.t
diffstat 1 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/spdy.t
+++ b/spdy.t
@@ -38,7 +38,7 @@ plan(skip_all => 'win32') if $^O eq 'MSW
 my $t = Test::Nginx->new()
 	->has(qw/http proxy cache limit_conn rewrite spdy realip/);
 
-$t->plan(76)->write_file_expand('nginx.conf', <<'EOF');
+$t->plan(79)->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
 
@@ -98,6 +98,15 @@ http {
         location /t3.html {
             limit_conn conn 1;
         }
+        location /set-cookie {
+            add_header Set-Cookie val1;
+            add_header Set-Cookie val2;
+            return 200;
+        }
+        location /cookie {
+            add_header X-Cookie $http_cookie;
+            return 200;
+        }
     }
 }
 
@@ -207,6 +216,43 @@ is($frame->{headers}->{':status'}, 206, 
 is($frame->{length}, 10, 'DATA length range');
 is($frame->{data}, '002XXXX000', 'DATA payload range');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.7.4');
+
+# request header with multiple values
+
+$sess = new_session();
+$sid1 = spdy_stream($sess, { path => '/cookie',
+	headers => { "cookie" =>  "val1\0val2" }
+});
+$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
+ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames),
+	'multiple request header values');
+
+# request header with multiple values proxied to http backend
+
+$sess = new_session();
+$sid1 = spdy_stream($sess, { path => '/proxy/cookie',
+	headers => { "cookie" =>  "val1\0val2" }
+});
+$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
+is($frame->{headers}->{'x-cookie'}, 'val1; val2',
+	'multiple request header values - proxied');
+
+}
+
+# response header with multiple values
+
+$sess = new_session();
+$sid1 = spdy_stream($sess, { path => '/set-cookie' });
+$frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
+is($frame->{headers}->{'set-cookie'}, "val1\0val2",
+	'response header with multiple values');
+
 # $spdy
 
 $sess = new_session();