--- /dev/null
+# match and set header with tags
+
+use strict;
+use warnings;
+
+my %header_client = (
+ "User-Agent" => "Mozilla Bla",
+ "MyHeader" => "UnmatchableContent",
+);
+
+our %args = (
+ client => {
+ func => \&http_client,
+ header => \%header_client,
+ len => 33,
+ },
+ relayd => {
+ protocol => [ "http",
+ # setting the User-Agent should succeed
+ 'match request header "User-Agent" value "Mozilla*" tag BORK',
+ 'match request header set "User-Agent" value "BORK" tagged BORK',
+ 'match request header log "User-Agent"',
+ # setting MyHeader should not happen
+ 'match request header "MyHeader" value "SomethingDifferent" tag FOO',
+ 'match request header set "MyHeader" value "FOO" tagged FOO',
+ 'match request header log "MyHeader"',
+ ],
+ loggrep => {
+ 'User-Agent: BORK' => 1,
+ 'MyHeader: FOO' => 0,
+ },
+ },
+ server => {
+ func => \&http_server,
+ loggrep => {
+ "User-Agent: BORK" => 1,
+ "MyHeader: FOO" => 0,
+ }
+ },
+ len => 33,
+);
+
+1;
-/* $OpenBSD: relay_http.c,v 1.27 2014/07/12 15:47:18 benno Exp $ */
+/* $OpenBSD: relay_http.c,v 1.28 2014/07/13 00:18:05 benno Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
} else if (match == NULL) {
/* Fail if header doesn't exist */
return (-1);
+ } else {
+ if (fnmatch(kv->kv_key, match->kv_key, FNM_CASEFOLD) == FNM_NOMATCH)
+ return (-1);
+ if (kv->kv_value != NULL &&
+ match->kv_value != NULL &&
+ fnmatch(kv->kv_value, match->kv_value, 0) == FNM_NOMATCH)
+ return (-1);
}
relay_match(actions, kv, match, &desc->http_headers);