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

support compressed data #4506

Merged
merged 5 commits into from
Feb 6, 2024
Merged

support compressed data #4506

merged 5 commits into from
Feb 6, 2024

Conversation

PSeitz
Copy link
Contributor

@PSeitz PSeitz commented Feb 5, 2024

closes #3990

#4215

kvargs["data"] = load_data(body_from_file)
kvargs["data"] = open(body_from_file, 'rb').read()
if body_from_file.endswith("gz"):
kvargs.setdefault("headers")["content-encoding"] = "gzip"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test with a gzip body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test already has gzip data (gharchive-bulk.json.gz), I just deactivated the client side decompression

/// searchable, so the second approach is more suitable for this use case.
async fn decompress_body(encoding: Option<String>, body: Bytes) -> Result<Bytes, warp::Rejection> {
match encoding.as_deref() {
Some("gzip" | "x-gzip") => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we improve this and make sure we return a 400 or a 406 with an error message for these errors. Right now all of them end up as a 500.

Copy link
Contributor

@fulmicoton fulmicoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http error handling

@fulmicoton fulmicoton merged commit 03477e8 into main Feb 6, 2024
4 checks passed
@fulmicoton fulmicoton deleted the compressed_http branch February 6, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support compressed HTTP request bodies in REST API
2 participants