Skip to content

Commit

Permalink
fix: include x-goog-gcs-idempotency-token in Json Resumable upload de…
Browse files Browse the repository at this point in the history
…bug context
  • Loading branch information
BenWhitehead committed Aug 25, 2023
1 parent c89d275 commit a525ed7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ enum JsonResumableSessionFailureScenario {
.or(matches("Content-Type"))
.or(matches("Range"))
.or(startsWith("X-Goog-Stored-"))
.or(matches("X-Goog-GCS-Idempotency-Token"))
.or(matches("X-GUploader-UploadID"));

private static final Predicate<Map.Entry<String, ?>> includeHeader =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ public void xGoogStoredHeadersIncludedIfPresent() throws IOException {
assertThat(storageException).hasMessageThat().contains("|< x-goog-stored-something: blah");
}

@Test
public void xGoogGcsIdempotencyTokenHeadersIncludedIfPresent() throws IOException {
HttpRequest req =
new MockHttpTransport()
.createRequestFactory()
.buildPutRequest(new GenericUrl("http://localhost:80980"), new EmptyContent());
req.getHeaders().setContentLength(0L);

HttpResponse resp = req.execute();
resp.getHeaders().set("X-Goog-Gcs-Idempotency-Token", "5").setContentLength(0L);

StorageException storageException =
JsonResumableSessionFailureScenario.SCENARIO_0.toStorageException(
"uploadId", resp, null, () -> null);

assertThat(storageException.getCode()).isEqualTo(0);
assertThat(storageException).hasMessageThat().contains("|< x-goog-gcs-idempotency-token: 5");
}

private static final class Cause extends RuntimeException {

private Cause() {
Expand Down

0 comments on commit a525ed7

Please sign in to comment.