aws / aws/aws-sdk-java-v2

Support gzip encoding in SdkHttpFullRequest

Open
#3,286 1 comment 1 reaction 1 assignee Claimed by @debora-ito View on GitHub
feature-request needs-triage
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

### Describe the feature

I'd like to be able to pass an uncompressed stream into `SdkHttpFullRequest.builder()` and have it do the compression for me. This is because I also want it to support chunked requests, and do Sigv4 signing "out of the box" for all these combinations.

```
String payload = "{\"test\": \"val\"}";

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
gzipOutputStream.write(payload.getBytes("UTF-8"));
gzipOutputStream.close();

SdkHttpFullRequest request = SdkHttpFullRequest.builder()
.method(SdkHttpMethod.POST)
.uri(URI.create(ENDPOINT + "/index_name/type_name/document_id"))
.appendHeader("Content-Type", "application/json")
.appendHeader("Content-Encoding", "gzip")
.contentStreamProvider(() -> new ByteArrayInputStream(outputStream.toByteArray()))
.build();
```

I found https://github.com/aws/aws-sdk-java-v2/issues/131 and https://github.com/aws/aws-sdk-java-v2/issues/866 but I don't think they are quite as specific as this.

### Use Case

Coming from https://github.com/dblock/aws-sdk-sigv4-demo where we attempt to make signed, compressed and chunked requests to Amazon OpenSearch.

### Proposed Solution

_No response_

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS Java SDK version used

2.17.224

### JDK version used

11

### Operating System and version

MacOS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.