Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ETag to Access-Control-Expose-Headers headers #668

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class CrossOriginResourceSharing {
private static final String ALLOW_ANY_ORIGIN = "*";
private static final String ALLOW_ANY_HEADER = "*";
private static final String ALLOW_CREDENTIALS = "true";
private static final String EXPOSED_HEADERS = "ETag";

private static final Logger logger = LoggerFactory.getLogger(
CrossOriginResourceSharing.class);
Expand Down Expand Up @@ -103,6 +104,10 @@ public CrossOriginResourceSharing(Collection<String> allowedOrigins,
logger.info("CORS allow credentials: {}", allowCredentials);
}

public String getExposedHeaders() {
return EXPOSED_HEADERS;
}

public String getAllowedMethods() {
return this.allowedMethodsRaw;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3012,6 +3012,8 @@ private void addCorsResponseHeader(HttpServletRequest request,
corsRules.isOriginAllowed(corsOrigin)) {
response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
corsRules.getAllowedOrigin(corsOrigin));
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS,
corsRules.getExposedHeaders());
response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
corsRules.getAllowedMethods());
if (corsRules.isAllowCredentials()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public void testCorsActual() throws Exception {
assertThat(response.getFirstHeader(
HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS).getValue())
.isEqualTo("GET, HEAD, PUT, POST, DELETE");
assertThat(response.getFirstHeader(
HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS).getValue())
.isEqualTo("ETag");
}

@Test
Expand Down
Loading