httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik600 <>
Subject strange behaviour using mod_proxy when the r->filename partially overlaps the requested uri
Date Tue, 21 Aug 2012 11:39:27 GMT
Dear all

i've got a strange behaviour in my custom module:

it seems that if the set filename overlaps the requested uri ths final
uri passed to mod_proxy is wrong, or has some added strange

some information:

* the module is activated only when the requested uri contains the
string "/files/anteprima"
* the module just redirect the request to mod_proxy changing the
request from "/files/anteprima" to "nocachedfiles/anteprima/"
* i know all is hardcoded here but is just to reproduce the problem

My module is configured in a vhost and related to a specific Location:

<Location /data>
    SetHandler kcache

if i make a request to this module, for example:

Looking at the code it should be redirected to:


but looking at apache logs i see:

[Tue Aug 21 13:27:01 2012] [debug] mod_proxy_http.c(56): proxy: HTTP:
canonicalising URL //
[Tue Aug 21 13:27:01 2012] [debug] proxy_util.c(1515): [client] proxy: *: found forward proxy worker for dJ\x98\x01\x7f
[Tue Aug 21 13:27:01 2012] [debug] mod_proxy_http.c(1973): proxy:
HTTP: serving URL
[Tue Aug 21 13:27:01 2012] [debug] proxy_util.c(2067): proxy:
dJ\x98\x01\x7f to

You can see some "garbage" at the end of the string.

I've tried to investigate a lot on in, but i'm not able to figure it
out... notice that if you change the length of the newurl string, or
if you change it from:


The module tries correctly to load withoud any
garbage at the end.

It seems to be a combination of overlaps of the requested uri, the
destination file and their length... here there is the exact code to
reproduce it:

One last thing :
is not yet clear to me if is correct to put this kind of redirection
in  ap_hook_translate_name or if i have to use another type of hook,
by the way if you use a ap_hook_handler in the same conditions you get
an http contatenated at the end of your filename:

[Tue Aug 21 13:37:02 2012] [debug] proxy_util.c(1515): [client] proxy: *: found forward proxy worker for

Any idea?

Thanks to all in advance

#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>

static void   register_hooks(apr_pool_t *pool);

module AP_MODULE_DECLARE_DATA kcache_module = {

static int kcache_handler_translate(request_rec* r)
    if (r->method_number != M_GET && r->method_number != M_POST){

		strstr(r->unparsed_uri, "/files/anteprima")==NULL){
		return DECLINED;
  	char *newurl = "proxy:";	

  	r->filename = apr_pcalloc(r->pool,strlen(newurl));
    r->proxyreq = PROXYREQ_PROXY;
    r->handler  = "proxy-server";

    return DECLINED;


static void register_hooks(apr_pool_t* pool)

	static const char *succ[] =
{"mod_proxy.c","mod_alias.c","mod_userdir.c", NULL};
    ap_hook_translate_name(kcache_handler_translate, NULL, succ,



View raw message