[master] d4b3c67 Set X-F-F early enough that it's present if we head directly to synth{}

Poul-Henning Kamp phk at FreeBSD.org
Mon Sep 8 21:52:56 CEST 2014


commit d4b3c674bce0e2ab607fdf9dc32222c88b9451dc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 8 19:52:31 2014 +0000

    Set X-F-F early enough that it's present if we head directly to synth{}

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index bd9b696..032c88d 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -697,6 +697,21 @@ cnt_recv(struct worker *wrk, struct req *req)
 
 	http_VSL_log(req->http);
 
+	if (req->restarts == 0) {
+		/*
+		 * This really should be done earlier, but we want to capture
+		 * it in the VSL log.
+		 */
+		if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) {
+			http_Unset(req->http, H_X_Forwarded_For);
+			http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s",
+			    xff, req->sp->client_addr_str);
+		} else {
+			http_PrintfHeader(req->http, "X-Forwarded-For: %s",
+			    req->sp->client_addr_str);
+		}
+	}
+
 	if (req->err_code) {
 		req->req_step = R_STP_SYNTH;
 		return (REQ_FSM_MORE);
@@ -712,25 +727,15 @@ cnt_recv(struct worker *wrk, struct req *req)
 	req->hash_always_miss = 0;
 	req->hash_ignore_busy = 0;
 	req->client_identity = NULL;
-	if (req->restarts == 0) {
-		if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) {
-			http_Unset(req->http, H_X_Forwarded_For);
-			http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s", xff,
-					  req->sp->client_addr_str);
-		} else {
-			http_PrintfHeader(req->http, "X-Forwarded-For: %s",
-					  req->sp->client_addr_str);
-		}
-	}
 
 	http_CollectHdr(req->http, H_Cache_Control);
 
 	VCL_recv_method(req->vcl, wrk, req, NULL, req->http->ws);
 
 	/* Attempts to cache req.body may fail */
-	if (req->req_body_status == REQ_BODY_FAIL) {
+	if (req->req_body_status == REQ_BODY_FAIL)
 		return (REQ_FSM_DONE);
-	}
+
 	recv_handling = wrk->handling;
 
 	/* We wash the A-E header here for the sake of VRY */



More information about the varnish-commit mailing list