Skip to content

Commit 1fc643d

Browse files
Clarifies the :path pseudo-header includes query params (#35)
Signed-off-by: Adrian Cole <[email protected]>
1 parent 988df77 commit 1fc643d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) t
133133
// and its request properties, but they may not be true of other proxies implementing
134134
// proxy-wasm.
135135

136-
path, err := proxywasm.GetHttpRequestHeader(":path")
136+
// Note the pseudo-header :path includes the query.
137+
// See https://httpwg.org/specs/rfc9113.html#rfc.section.8.3.1
138+
uri, err := proxywasm.GetHttpRequestHeader(":path")
137139
if err != nil {
138140
proxywasm.LogCriticalf("failed to get :path: %v", err)
139141
return types.ActionContinue
@@ -154,7 +156,7 @@ func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) t
154156

155157
ctx.httpProtocol = string(protocol)
156158

157-
tx.ProcessURI(path, method, ctx.httpProtocol)
159+
tx.ProcessURI(uri, method, ctx.httpProtocol)
158160

159161
hs, err := proxywasm.GetHttpRequestHeaders()
160162
if err != nil {

main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func checkTXMetric(t *testing.T, host proxytest.HostEmulator, expectedCounter in
2424

2525
func TestLifecycle(t *testing.T) {
2626
reqHdrs := [][2]string{
27-
{":path", "/hello"},
27+
{":path", "/hello?name=panda"},
2828
{":method", "GET"},
2929
{":authority", "localhost"},
3030
{"User-Agent", "gotest"},
@@ -69,7 +69,7 @@ SecRuleEngine On\nSecRule REQUEST_URI \"@streq /admin\" \"id:101,phase:1,t:lower
6969
{
7070
name: "url denied",
7171
inlineRules: `
72-
SecRuleEngine On\nSecRule REQUEST_URI \"@streq /hello\" \"id:101,phase:1,t:lowercase,deny\"
72+
SecRuleEngine On\nSecRule REQUEST_URI \"@streq /hello?name=panda\" \"id:101,phase:1,t:lowercase,deny\"
7373
`,
7474
requestHdrsAction: types.ActionPause,
7575
requestBodyAction: types.ActionContinue,

0 commit comments

Comments
 (0)