--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ len => 1,
+ loggrep => { "X-Server-Append: 127.0.0.1:.*" => 1 },
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request header append "$REMOTE_ADDR:$REMOTE_PORT" to X-Client-Append',
+ 'response header append "$SERVER_ADDR:$SERVER_PORT" to X-Server-Append',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ loggrep => { "X-Client-Append: 127.0.0.1:.*" => 1 },
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+my %header = ("X-Test-Header" => "XOriginalValue");
+our %args = (
+ client => {
+ func => \&http_client,
+ nocheck => 1,
+ loggrep => {
+ qr/X-Test-Header: XChangedValue/ => 1,
+ qr/Host: foo.bar/ => 1,
+ }
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request header change "Host" to "foobar.changed"',
+ 'response header change "X-Test-Header" to "XChangedValue"',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ header => \%header,
+ loggrep => {
+ qr/X-Test-Header: XOriginalValue/ => 1,
+ qr/Host: foobar.changed/ => 1,
+ },
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+my @lengths = (21);
+our %args = (
+ client => {
+ func => \&http_client,
+ lengths => \@lengths,
+ path => "query?foo=bar&ok=yes"
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request query expect "bar" from "foo" log',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ },
+ lengths => \@lengths,
+);
+
+1;
--- /dev/null
+# test http block
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub { eval { http_client(@_) }; warn $@ },
+ loggrep => qr/Client missing http 251 response/,
+ cookie => "med=thx; domain=.foo.bar; path=/; expires=Mon, 27-Oct-2014 04:11:56 GMT;",
+ path => "anypath",
+ nocheck => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request cookie filter "thx" from "med" log',
+ ],
+ loggrep => qr/rejecting request, \[med: thx\]/,
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "a/b/c/d/e/f/gindex.html",
+ loggrep => [
+ qr/403 Forbidden/,
+ qr/Server: OpenBSD relayd/,
+ qr/Connection: close/,
+ ],
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'request url filter "foo.bar/a/b/" log',
+ ],
+ loggrep => {
+ qr/rejecting request \(403 Forbidden\)/ => 1,
+ qr/\[foo.bar\/a\/b\/:/ => 1,
+ },
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "query?foobar",
+ len => 21,
+ nocheck => 1,
+ },
+ relayd => {
+ table => 1,
+ protocol => [ "http",
+ 'path hash "/query" log',
+ ],
+ relay => 'forward to <table-$test> port $connectport',
+ loggrep => {
+ qr/done, \[\/query: foobar\]/ => 1,
+ qr/relay_handle_http: hash 0xfde460be/ => 1,
+ },
+ },
+ server => {
+ func => \&http_server,
+ nocheck => 1,
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ loggrep => qr/403 Forbidden/,
+ path => "query?foo=bar&ok=yes",
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'label "expect_foobar_label"',
+ 'request query filter "bar" from "foo" log',
+ 'no label',
+ ],
+ loggrep => qr/.*403 Forbidden.*expect_foobar_label.*foo: bar/,
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "foobar?path",
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request path mark "*" from "/foobar" with 55',
+ 'request path change "path" to "foobarchangedpath" marked 55',
+ ],
+ loggrep => { ", 55,.*done" => 1 },
+ },
+ server => {
+ func => \&http_server,
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+my %header = (
+ "X-Header-Foo" => "foo",
+ "X-Header-Bar" => "bar",
+);
+our %args = (
+ client => {
+ func => \&http_client,
+ loggrep => {
+ "X-Header-Foo: foo" => 0,
+ "X-Header-Bar: bar" => 1,
+ },
+ },
+ relayd => {
+ protocol => [ "http",
+ 'response header remove X-Header-Foo log',
+ ],
+ loggrep => { qr/done, \[X-Header-Foo: foo\s*\]/ => 1 },
+ },
+ server => {
+ func => \&http_server,
+ header => \%header,
+ loggrep => {
+ "X-Header-Foo: foo" => 1,
+ "X-Header-Bar: bar" => 1,
+ },
+ },
+);
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ # XXX add more paths to match a case where it pass
+ path => "query?foo=bar&ok=yes",
+ nocheck => 1,
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'label "expect_foobar_return_test"',
+ 'request query expect "baz" from "foo" log',
+ 'no label',
+ ],
+ loggrep => {
+ ' \(403 Forbidden\), \[expect_foobar_return_test, foo: bar\]' => 1
+ },
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;