Browse Source

[mod_redirect,mod_rewrite] pass request URI info

personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
37900d24b3
  1. 7
      src/burl.h
  2. 2
      src/keyvalue.h
  3. 7
      src/mod_redirect.c
  4. 7
      src/mod_rewrite.c

7
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

2
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;

7
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

7
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) {

Loading…
Cancel
Save