Skip to content

Commit 4da6855

Browse files
committed
Keep user context headers in debug mode
To improve debugging, and to be consistent with other cleanup keep headers if we are in debug mode.
1 parent fa2239e commit 4da6855

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

resources/config/varnish-3/fos_user_context.vcl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,18 @@ sub fos_user_context_deliver {
8888
return (restart);
8989
}
9090

91-
# If we get here, this is a real response that gets sent to the client.
92-
93-
# Remove the vary on context user hash, this is nothing public. Keep all
94-
# other vary headers.
95-
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
96-
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
97-
if (resp.http.Vary == "") {
98-
remove resp.http.Vary;
99-
}
91+
# If we get here, this is a real response that gets sent to the client and we do some cleanup if not in debug.
92+
93+
if (!resp.http.X-Cache-Debug) {
94+
# Remove the vary on context user hash, this is nothing public. Keep all
95+
# other vary headers.
96+
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
97+
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
98+
if (resp.http.Vary == "") {
99+
remove resp.http.Vary;
100+
}
100101

101-
# Sanity check to prevent ever exposing the hash to a client.
102-
remove resp.http.X-User-Context-Hash;
102+
# Sanity check to prevent ever exposing the hash to a client.
103+
remove resp.http.X-User-Context-Hash;
104+
}
103105
}

resources/config/varnish/fos_user_context.vcl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,18 @@ sub fos_user_context_deliver {
8686
return (restart);
8787
}
8888

89-
# If we get here, this is a real response that gets sent to the client.
90-
91-
# Remove the vary on context user hash, this is nothing public. Keep all
92-
# other vary headers.
93-
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
94-
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
95-
if (resp.http.Vary == "") {
96-
unset resp.http.Vary;
97-
}
89+
# If we get here, this is a real response that gets sent to the client and we do some cleanup if not in debug.
90+
91+
if (!resp.http.X-Cache-Debug) {
92+
# Remove the vary on context user hash, this is nothing public. Keep all
93+
# other vary headers.
94+
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
95+
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
96+
if (resp.http.Vary == "") {
97+
unset resp.http.Vary;
98+
}
9899

99-
# Sanity check to prevent ever exposing the hash to a client.
100-
unset resp.http.X-User-Context-Hash;
100+
# Sanity check to prevent ever exposing the hash to a client.
101+
unset resp.http.X-User-Context-Hash;
102+
}
101103
}

0 commit comments

Comments
 (0)