diff --git a/src/burl.h b/src/burl.h index d81cc572..a7d45563 100644 --- a/src/burl.h +++ b/src/burl.h @@ -4,6 +4,13 @@ #include "buffer.h" +struct burl_parts_t { + buffer *scheme; + buffer *authority; + buffer *path; + buffer *query; +}; + enum burl_opts_e { HTTP_PARSEOPT_HEADER_STRICT = 0x1 ,HTTP_PARSEOPT_HOST_STRICT = 0x2 diff --git a/src/keyvalue.h b/src/keyvalue.h index b50e7615..0a785484 100644 --- a/src/keyvalue.h +++ b/src/keyvalue.h @@ -5,11 +5,13 @@ #include "base_decls.h" #include "buffer.h" +struct burl_parts_t; /* declaration */ struct cond_cache_t; /* declaration */ struct pcre_keyvalue; /* declaration */ typedef struct pcre_keyvalue_ctx { struct cond_cache_t *cache; + struct burl_parts_t *burl; int m; } pcre_keyvalue_ctx; diff --git a/src/mod_redirect.c b/src/mod_redirect.c index 51bffa2d..3d863649 100644 --- a/src/mod_redirect.c +++ b/src/mod_redirect.c @@ -4,6 +4,7 @@ #include "keyvalue.h" #include "log.h" #include "buffer.h" +#include "burl.h" #include "plugin.h" #include "response.h" @@ -147,6 +148,7 @@ static int mod_redirect_patch_connection(server *srv, connection *con, plugin_da URIHANDLER_FUNC(mod_redirect_uri_handler) { plugin_data *p = p_d; + struct burl_parts_t burl; pcre_keyvalue_ctx ctx; handler_t rc; @@ -155,6 +157,11 @@ URIHANDLER_FUNC(mod_redirect_uri_handler) { ctx.cache = p->conf.context ? &con->cond_cache[p->conf.context->context_ndx] : NULL; + ctx.burl = &burl; + burl.scheme = con->uri.scheme; + burl.authority = con->uri.authority; + burl.path = con->uri.path_raw; + burl.query = con->uri.query; /* redirect URL on match * e.g. redirect /base/ to /index.php?section=base diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c index 2b8239c9..39441bcb 100644 --- a/src/mod_rewrite.c +++ b/src/mod_rewrite.c @@ -4,6 +4,7 @@ #include "keyvalue.h" #include "log.h" #include "buffer.h" +#include "burl.h" #include "plugin.h" #include "stat_cache.h" @@ -230,6 +231,7 @@ URIHANDLER_FUNC(mod_rewrite_con_reset) { static handler_t process_rewrite_rules(server *srv, connection *con, plugin_data *p, pcre_keyvalue_buffer *kvb, int repeat_idx) { handler_ctx *hctx; + struct burl_parts_t burl; pcre_keyvalue_ctx ctx; handler_t rc; @@ -248,6 +250,11 @@ static handler_t process_rewrite_rules(server *srv, connection *con, plugin_data } ctx.cache = p->conf.context ? &con->cond_cache[p->conf.context->context_ndx] : NULL; + ctx.burl = &burl; + burl.scheme = con->uri.scheme; + burl.authority = con->uri.authority; + burl.path = con->uri.path_raw; + burl.query = con->uri.query; rc = pcre_keyvalue_buffer_process(kvb, &ctx, con->request.uri, srv->tmp_buf); if (HANDLER_FINISHED == rc) {