[mod_proxy] use raw_path instead of re-encoded path

personal/stbuehler/wip
Stefan Bühler 9 years ago
parent 6e2ca4b80c
commit b5eac15433

@ -7,6 +7,11 @@
<parameter name="socket">
<short>socket to connect to, either "ip:port" or "unix:/path"</short>
</parameter>
<description>
<textile><![CDATA[
proxy combines @request.raw_path@ and @request.query@ for the URL to send to the backend.
]]></textile>
</description>
<example>
<config>
setup {

@ -42,16 +42,13 @@ static void proxy_send_headers(liVRequest *vr, liChunkQueue *out) {
GString *head = g_string_sized_new(4095);
liHttpHeader *header;
GList *iter;
gchar *enc_path;
liHttpHeaderTokenizer header_tokenizer;
GString *tmp_str = vr->wrk->tmp_str;
g_string_append_len(head, GSTR_LEN(vr->request.http_method_str));
g_string_append_len(head, CONST_STR_LEN(" "));
enc_path = g_uri_escape_string(vr->request.uri.path->str, "/", FALSE);
g_string_append(head, enc_path);
g_free(enc_path);
g_string_append_len(head, GSTR_LEN(vr->request.uri.raw_path));
if (vr->request.uri.query->len > 0) {
g_string_append_len(head, CONST_STR_LEN("?"));

@ -12,9 +12,47 @@ self_proxy;
"""
no_docroot = True
# need vhost for next test
class TestEncodedURL(CurlRequest):
URL = "/some%2Ffile"
EXPECT_RESPONSE_BODY = "/dest%2Ffile"
EXPECT_RESPONSE_CODE = 200
no_docroot = True
config = """
rewrite_raw "/some(%2F.*)" => "/dest$1";
respond 200 => "%{req.raw_path}";
"""
# backend gets encoded %2F and rewrites again
class TestProxiedRewrittenEncodedURL(CurlRequest):
URL = "/foo%2Ffile"
EXPECT_RESPONSE_BODY = "/dest%2Ffile"
EXPECT_RESPONSE_CODE = 200
no_docroot = True
config = """
rewrite_raw "/foo(.*)" => "/some$1";
req_header.overwrite "Host" => "encodedurl.mod-proxy";
self_proxy;
"""
# backend gets decoded %2F and doesn't rewrite again
class TestProxiedRewrittenDecodedURL(CurlRequest):
URL = "/foo%2Ffile"
EXPECT_RESPONSE_BODY = "/some/file"
EXPECT_RESPONSE_CODE = 200
no_docroot = True
config = """
rewrite "/foo(.*)" => "/some$1";
req_header.overwrite "Host" => "encodedurl.mod-proxy";
self_proxy;
"""
class Test(GroupTest):
group = [
TestSimple,
TestEncodedURL,
TestProxiedRewrittenEncodedURL,
TestProxiedRewrittenDecodedURL,
]
def Prepare(self):

Loading…
Cancel
Save