|
31 | 31 | import javax.servlet.http.HttpServletRequest;
|
32 | 32 | import javax.servlet.http.HttpServletResponse;
|
33 | 33 |
|
34 |
| -import org.eclipse.jetty.http.HttpField; |
35 |
| -import org.eclipse.jetty.http.HttpHeader; |
36 |
| -import org.eclipse.jetty.http.PreEncodedHttpField; |
37 |
| -import org.eclipse.jetty.server.Response; |
38 | 34 | import org.eclipse.jetty.util.StringUtil;
|
39 | 35 | import org.slf4j.Logger;
|
40 | 36 | import org.slf4j.LoggerFactory;
|
@@ -153,7 +149,6 @@ public class CrossOriginFilter implements Filter
|
153 | 149 | private static final List<String> SIMPLE_HTTP_METHODS = Arrays.asList("GET", "POST", "HEAD");
|
154 | 150 | private static final List<String> DEFAULT_ALLOWED_METHODS = Arrays.asList("GET", "POST", "HEAD");
|
155 | 151 | private static final List<String> DEFAULT_ALLOWED_HEADERS = Arrays.asList("X-Requested-With", "Content-Type", "Accept", "Origin");
|
156 |
| - private static final HttpField VARY_ORIGIN = new PreEncodedHttpField(HttpHeader.VARY, HttpHeader.ORIGIN.asString()); |
157 | 152 |
|
158 | 153 | private boolean anyOriginAllowed;
|
159 | 154 | private boolean anyTimingOriginAllowed;
|
@@ -274,10 +269,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
|
274 | 269 |
|
275 | 270 | private void handle(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException
|
276 | 271 | {
|
277 |
| - if (response instanceof Response) |
278 |
| - ((Response)response).getHttpFields().add(VARY_ORIGIN); |
279 |
| - else |
280 |
| - response.addHeader(VARY_ORIGIN.getName(), VARY_ORIGIN.getValue()); |
| 272 | + response.addHeader("Vary", ORIGIN_HEADER); |
281 | 273 | String origin = request.getHeader(ORIGIN_HEADER);
|
282 | 274 | // Is it a cross origin request ?
|
283 | 275 | if (origin != null && isEnabled(request))
|
|
0 commit comments