Software /
code /
prosody
Comparison
spec/util_http_spec.lua @ 13124:f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Standardized and structured replacement for the X-Forwarded-For,
X-Forwarded-Proto set of headers.
Notably, this allows per-hop protocol information, unlike
X-Forwarded-Proto which is always a single value for some reason.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 03 Jun 2023 16:15:52 +0200 |
parent | 10711:d2e4584ba7b3 |
comparison
equal
deleted
inserted
replaced
13123:dee26e4cfb2b | 13124:f15e23840780 |
---|---|
106 | 106 |
107 it("is weird", function () | 107 it("is weird", function () |
108 assert.is_(http.contains_token("fo o", "foo")); | 108 assert.is_(http.contains_token("fo o", "foo")); |
109 end); | 109 end); |
110 end); | 110 end); |
111 | |
112 do | |
113 describe("parse_forwarded", function() | |
114 it("works", function() | |
115 assert.same({ { ["for"] = "[2001:db8:cafe::17]:4711" } }, http.parse_forwarded('For="[2001:db8:cafe::17]:4711"'), "case insensitive"); | |
116 | |
117 assert.same({ { ["for"] = "192.0.2.60"; proto = "http"; by = "203.0.113.43" } }, http.parse_forwarded('for=192.0.2.60;proto=http;by=203.0.113.43'), | |
118 "separated by semicolon"); | |
119 | |
120 assert.same({ { ["for"] = "192.0.2.43" }; { ["for"] = "198.51.100.17" } }, http.parse_forwarded('for=192.0.2.43, for=198.51.100.17'), | |
121 "Values from multiple proxy servers can be appended using a comma"); | |
122 | |
123 end) | |
124 it("rejects quoted quotes", function () | |
125 assert.falsy(http.parse_forwarded('foo="bar\"bar'), "quoted quotes"); | |
126 end) | |
127 pending("deals with quoted quotes", function () | |
128 assert.same({ { foo = 'bar"baz' } }, http.parse_forwarded('foo="bar\"bar'), "quoted quotes"); | |
129 end) | |
130 end) | |
131 end | |
111 end); | 132 end); |