Skip to content

Commit

Permalink
Add ETag to failed conditional GETs
Browse files Browse the repository at this point in the history
Found via s3-tests.  References apache/jclouds#209.
  • Loading branch information
gaul committed Sep 4, 2024
1 parent 3d2beb3 commit cb443b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/org/gaul/s3proxy/S3ProxyHandlerJetty.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.annotation.Nullable;

import com.google.common.collect.ImmutableMap;
import com.google.common.net.HttpHeaders;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -94,6 +95,12 @@ public void handle(String target, Request baseRequest,
hre.getMessage());
return;
}

String eTag = hr.getFirstHeaderOrNull(HttpHeaders.ETAG);
if (eTag != null) {
response.setHeader(HttpHeaders.ETAG, eTag);
}

int status = hr.getStatusCode();
switch (status) {
case 412:
Expand All @@ -111,7 +118,7 @@ public void handle(String target, Request baseRequest,
break;
default:
logger.debug("HttpResponseException:", hre);
response.sendError(status, hre.getContent());
response.setStatus(status);
break;
}
baseRequest.setHandled(true);
Expand Down

0 comments on commit cb443b7

Please sign in to comment.