marc 97/08/23 15:59:13
Modified: apachen/src CHANGES
apachen/src/modules/proxy mod_proxy.h proxy_cache.c
proxy_http.c proxy_util.c
Log:
Fix the proxy to set r->headers_out when sending responses. Wherever
a header is sent, it is added to headers_out. This is necessary to
allow things like logging based on outbound headers to work properly.
PR: 569
Reviewed by: Dean Gaudet
Revision Changes Path
1.413 +4 -0 /apachen/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs//apachen/src/CHANGES,v
retrieving revision 1.412
retrieving revision 1.413
diff -u -r1.412 -r1.413
--- CHANGES 1997/08/23 12:15:32 1.412
+++ CHANGES 1997/08/23 22:59:08 1.413
@@ -1,5 +1,9 @@
Changes with Apache 1.3a2
+ *) Set r->headers_out when sending responses from the proxy.
+ This fixes things such as the logging of headers sent from
+ the proxy. PR#659 [Marc Slemko]
+
*) support/httpd_monitor is no longer distributed because the
scoreboard should not be file based if at all possible. Use
mod_status to see current server snapshot.
1.19 +2 -1 /apachen/src/modules/proxy/mod_proxy.h
Index: mod_proxy.h
===================================================================
RCS file: /export/home/cvs//apachen/src/modules/proxy/mod_proxy.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- mod_proxy.h 1997/08/17 13:56:26 1.18
+++ mod_proxy.h 1997/08/23 22:59:10 1.19
@@ -266,7 +266,8 @@
struct hdr_entry *proxy_add_header(array_header *hdrs_arr, char *field,
char *value, int rep);
void proxy_del_header(array_header *hdrs_arr, const char *field);
-void proxy_send_headers(BUFF *fp, const char *respline, array_header
*hdrs_arr);
+void proxy_send_headers(request_rec *r, const char *respline,
+ array_header *hdrs_arr);
int proxy_liststr(const char *list, const char *val);
void proxy_hash(const char *it, char *val,int ndepth,int nlength);
int proxy_hex2sec(const char *x);
1.24 +2 -3 /apachen/src/modules/proxy/proxy_cache.c
Index: proxy_cache.c
===================================================================
RCS file: /export/home/cvs//apachen/src/modules/proxy/proxy_cache.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- proxy_cache.c 1997/08/17 13:56:27 1.23
+++ proxy_cache.c 1997/08/23 22:59:11 1.24
@@ -571,7 +571,7 @@
r->status = c->status;
if (!r->assbackwards) {
soft_timeout("proxy send headers", r);
- proxy_send_headers(r->connection->client, c->resp_line, c->hdrs);
+ proxy_send_headers(r, c->resp_line, c->hdrs);
kill_timeout(r);
}
bsetopt(r->connection->client, BO_BYTECT, &zero);
@@ -800,8 +800,7 @@
r->status = c->status;
if (!r->assbackwards) {
soft_timeout("proxy send headers", r);
- proxy_send_headers(r->connection->client, c->resp_line,
- c->hdrs);
+ proxy_send_headers(r, c->resp_line, c->hdrs);
kill_timeout(r);
}
bsetopt(r->connection->client, BO_BYTECT, &zero);
1.29 +3 -1 /apachen/src/modules/proxy/proxy_http.c
Index: proxy_http.c
===================================================================
RCS file: /export/home/cvs//apachen/src/modules/proxy/proxy_http.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- proxy_http.c 1997/08/23 04:57:03 1.28
+++ proxy_http.c 1997/08/23 22:59:11 1.29
@@ -397,8 +397,10 @@
{
if (hdr[i].field == NULL || hdr[i].value == NULL ||
hdr[i].value[0] == '\0') continue;
- if (!r->assbackwards)
+ if (!r->assbackwards) {
rvputs(r, hdr[i].field, ": ", hdr[i].value, "\015\012", NULL);
+ table_set(r->headers_out, hdr[i].field, hdr[i].value);
+ }
if (cache != NULL)
if (bvputs(cache, hdr[i].field, ": ", hdr[i].value, "\015\012",
NULL) == -1)
1.24 +7 -2 /apachen/src/modules/proxy/proxy_util.c
Index: proxy_util.c
===================================================================
RCS file: /export/home/cvs//apachen/src/modules/proxy/proxy_util.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- proxy_util.c 1997/08/18 00:12:23 1.23
+++ proxy_util.c 1997/08/23 22:59:11 1.24
@@ -512,14 +512,18 @@
}
/*
- * Sends response line and headers
+ * Sends response line and headers. Uses the client fd and the
+ * headers_out array from the passed request_rec to talk to the client
+ * and to properly set the headers it sends for things such as logging.
+ *
* A timeout should be set before calling this routine.
*/
void
-proxy_send_headers(BUFF *fp, const char *respline, array_header *hdrs_arr)
+proxy_send_headers(request_rec *r, const char *respline, array_header
*hdrs_arr)
{
struct hdr_entry *hdrs;
int i;
+ BUFF *fp = r->connection->client;
hdrs = (struct hdr_entry *)hdrs_arr->elts;
@@ -529,6 +533,7 @@
{
if (hdrs[i].field == NULL) continue;
bvputs(fp, hdrs[i].field, ": ", hdrs[i].value, "\015\012", NULL);
+ table_set(r->headers_out, hdrs[i].field, hdrs[i].value);
}
bputs("\015\012", fp);