You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by gw...@fscinternet.com on 2002/07/23 20:06:11 UTC
Local redirect seems to mangle original request_rec
I've noticed a problem when using custom error pages in Apache 2.0.39:
the original request_rec and the local redirect request_rec seem to get
intermingled. I.e. some of the request_rec members from the original
(top-level) request_rec seem to get written into the child request_rec,
and vice versa.
A simple module that logs members of request_rec is included below.
For example:
If a request is made that will result in a 403 (due to a deny from all
in the config file):
POST /foo HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 5
abc=5
and a custom 403 document is defined:
ErrorDocument 403 /errors /403.html
Then here's the log output (generated by the attached module):
(log data from the main request_rec, i.e. for the original POST
operation)
[Tue Jul 23 13:18:58 2002] [warn]
-----------------------------------------------------
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->method: GET
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->method_number: 0
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->status: 403
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->the_request: POST /foo
HTTP/1.0
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->uri: /foo
[Tue Jul 23 13:18:58 2002] [warn] mod_test: HEADERIN: Content-Type =
application/x-www-form-urlencoded
[Tue Jul 23 13:18:58 2002] [warn] mod_test: HEADERIN: Content-Length = 5
(log data from the child request_rec, i.e. for the redirected 403
operation)
[Tue Jul 23 13:18:58 2002] [warn]
-----------------------------------------------------
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->method: GET
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->method_number: 0
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->status: 403
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->the_request: POST /foo
HTTP/1.0
[Tue Jul 23 13:18:58 2002] [warn] mod_test: r->uri: /errors/403.html
[Tue Jul 23 13:18:58 2002] [warn] mod_test: HEADERIN: Content-Type =
application/x-www-form-urlencoded
[Tue Jul 23 13:18:58 2002] [warn] mod_test: HEADERIN: Content-Length = 5
Notice r->method for the original request is GET, when it should be
POST. Also r->the_request is same for both, while r->uri differs.
I'm not sure if this is a bug, or if I'm doing something wrong... Any
ideas?
(I've attached the test module that generates the log output shown
above, as well as the relevant parts of httpd.conf).
Thanks,
Graham Wiseman
gwiseman@fscinternet.com
FSC Internet Corp.
Some relevant parts of httpd.conf:
LoadModule test_module modules/mod_test.so
LoadModule access_module modules/mod_access.so
LoadModule log_config_module modules/mod_log_config.so
DocumentRoot "/var/htdocs"
<Directory "/var/htdocs">
Options None
AllowOverride None
Order allow,deny
deny from all
</Directory>
<Directory "/var/htdocs/errors">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ErrorDocument 403 /errors/403.html
----------------------------------------Begin
mod_test.c----------------------------------------
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_protocol.h"
#include "ap_config.h"
static void test_log_record(request_rec *r);
static int test_log_transaction(request_rec *r)
{
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"****************************************");
test_log_record(r);
while (r->next) {
r = r->next;
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0,
r->server,
"****************************************");
test_log_record(r);
}
return OK;
}
static void test_log_record(request_rec *r)
{
int i;
apr_table_entry_t *elts;
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"mod_test: %s: %s", "r->method", r->method);
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"mod_test: %s: %d", "r->method_number",
r->method_number);
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"mod_test: %s: %d", "r->status", r->status);
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"mod_test: %s: %s", "r->the_request", r->the_request);
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0, r->server,
"mod_test: %s: %s", "r->uri", r->uri);
elts = (apr_table_entry_t *) apr_table_elts(r->headers_in)->elts;
for (i = 0; i < apr_table_elts(r->headers_in)->nelts; i++)
ap_log_error(APLOG_MARK, APLOG_WARNING, (apr_status_t) 0,
r->server,
"mod_test: HEADERIN: %s = %s",
elts[i].key, elts[i].val);
return;
}
static void test_register_hooks(apr_pool_t *p)
{
ap_hook_log_transaction(test_log_transaction, NULL, NULL,
APR_HOOK_LAST);
}
module AP_MODULE_DECLARE_DATA test_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
test_register_hooks
};
----------------------------------------End
mod_test.c----------------------------------------