summaryrefslogtreecommitdiff
path: root/regress/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2014-07-10 11:56:12 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2014-07-10 11:56:12 +0000
commit5630c0d838b49d1d2a6ab354f63c2d84eca7bf14 (patch)
tree3f25867f716810b5437b87c98e0591de82d30e10 /regress/usr.sbin
parent22b2fd5839248fedaf624730ecac77d4691b5ebf (diff)
Add support to test handling of repeated headers.
From RFC 7230, section 3.2.2: "A sender MUST NOT generate multiple header fields with the same field name in a message unless either the entire field value for that header field is defined as a comma-separated list [i.e., #(values)] or the header field is a well-known exception (as noted below)."
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r--regress/usr.sbin/relayd/args-http-change-cookie.pl27
-rw-r--r--regress/usr.sbin/relayd/funcs.pl22
2 files changed, 46 insertions, 3 deletions
diff --git a/regress/usr.sbin/relayd/args-http-change-cookie.pl b/regress/usr.sbin/relayd/args-http-change-cookie.pl
new file mode 100644
index 00000000000..ac0dd71c83f
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-change-cookie.pl
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+my $name = "X-Set-Cookie";
+my %header = ("$name" => [ "test=a;", "test=b;" ]);
+our %args = (
+ client => {
+ func => \&http_client,
+ loggrep => {
+ qr/$name: test=c/ => 1,
+ }
+ },
+ relayd => {
+ protocol => [ "http",
+ 'match response header set "'.$name.'" value "test=c"',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ header => \%header,
+ loggrep => {
+ qr/$name: test=a/ => 1
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/funcs.pl b/regress/usr.sbin/relayd/funcs.pl
index bb0256af641..5ab7d5279f3 100644
--- a/regress/usr.sbin/relayd/funcs.pl
+++ b/regress/usr.sbin/relayd/funcs.pl
@@ -1,4 +1,4 @@
-# $OpenBSD: funcs.pl,v 1.13 2014/07/10 10:19:06 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.14 2014/07/10 11:56:11 reyk Exp $
# Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -139,7 +139,15 @@ sub http_request {
push @request, "Content-Length: $len"
if $vers eq "1.1" && $method eq "PUT" &&
!defined $header{'Content-Length'};
- push @request, "$_: $header{$_}" foreach sort keys %header;
+ foreach my $key (sort keys %header) {
+ my $val = $header{$key};
+ if (ref($val) eq 'ARRAY') {
+ push @request, "$key: $_"
+ foreach @{$val};
+ } else {
+ push @request, "$key: $val";
+ }
+ }
push @request, "Cookie: $cookie" if $cookie;
push @request, "";
print STDERR map { ">>> $_\n" } @request;
@@ -306,7 +314,15 @@ sub http_server {
push @response, "Content-Length: $len"
if $vers eq "1.1" && $method eq "GET";
}
- push @response, "$_: $header{$_} " foreach sort keys %header;
+ foreach my $key (sort keys %header) {
+ my $val = $header{$key};
+ if (ref($val) eq 'ARRAY') {
+ push @response, "$key: $_"
+ foreach @{$val};
+ } else {
+ push @response, "$key: $val";
+ }
+ }
push @response, "Set-Cookie: $cookie" if $cookie;
push @response, "";