Skip to content

Commit ee35f39

Browse files
nicktindallafoucret
authored andcommitted
GCS: Use idempotency token to identify requests (#126887)
1 parent 2594b10 commit ee35f39

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStoreRepositoryTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ private static class GoogleCloudStorageBlobStoreHttpHandler extends GoogleCloudS
325325
@SuppressForbidden(reason = "this test uses a HttpServer to emulate a Google Cloud Storage endpoint")
326326
private static class GoogleErroneousHttpHandler extends ErroneousHttpHandler {
327327

328+
private static final String IDEMPOTENCY_TOKEN = "x-goog-gcs-idempotency-token";
329+
328330
GoogleErroneousHttpHandler(final HttpHandler delegate, final int maxErrorsPerRequest) {
329331
super(delegate, maxErrorsPerRequest);
330332
}
@@ -340,6 +342,10 @@ protected String requestUniqueId(HttpExchange exchange) {
340342
}
341343
}
342344

345+
if (exchange.getRequestHeaders().containsKey(IDEMPOTENCY_TOKEN)) {
346+
return exchange.getRequestHeaders().getFirst(IDEMPOTENCY_TOKEN);
347+
}
348+
343349
final String range = exchange.getRequestHeaders().getFirst("Content-Range");
344350
return exchange.getRemoteAddress().getHostString()
345351
+ " "

0 commit comments

Comments
 (0)