Skip to content

Commit

Permalink
BZ61101: CORS filter should set Vary header in response. Submitted by…
Browse files Browse the repository at this point in the history
… Rick Riemer.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1795813 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rmaucher committed May 22, 2017
1 parent 5edb50d commit b94478d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions java/org/apache/catalina/filters/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ protected void handleSimpleCORS(final HttpServletRequest request,
exposedHeadersString);
}

// Indicate the response depends on the origin
response.addHeader(CorsFilter.REQUEST_HEADER_VARY,
CorsFilter.REQUEST_HEADER_ORIGIN);

// Forward the request down the filter chain.
filterChain.doFilter(request, response);
}
Expand Down Expand Up @@ -966,6 +970,13 @@ public Collection<String> getAllowedHttpHeaders() {
"Access-Control-Allow-Headers";

// -------------------------------------------------- CORS Request Headers

/**
* The Vary header indicates allows disabling proxy caching by indicating
* the the response depends on the origin.
*/
public static final String REQUEST_HEADER_VARY = "Vary";

/**
* The Origin header indicates where the cross-origin request or preflight
* request originates from.
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
<code>o.a.c.connector.CoyoteAdapter#parseSessionCookiesId</code>.
Patch provided by John Andrew (XUZHOUWANG) via Github. (violetagg)
</fix>
<fix>
<bug>61101</bug>: CORS filter should set Vary header in response.
Submitted by Rick Riemer. (remm)
</fix>
</changelog>
</subsection>
<subsection name="Coyote">
Expand Down

0 comments on commit b94478d

Please sign in to comment.