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

doc: adds automatic decompression information #97

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion middleware/DecompressionHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ A middleware component that requests, detects and decompresses response bodies.

For request payload compression, refer to the [compression handler](./CompressionHandler.md) specification.

This middleware is currently not required in JavaScript as the Fetch API already supports decompressing responses automatically and automatically adds the accept-encoding header. If Microsoft Graph accepts compressed responses at some point in the future then we should add request compression middleware to Javascript also.
## State of automatic decompression

The following table describes the state of automatic decompression of responses. When automatic decompression is supported, we don't need to implement it manually.

| Language | Client | Automatic decompression | Source | Notes |
| -------- | ------ | ----------------------- | ------ | ----- |
| CSharp | HttpClient | Yes | [link](https://learn.microsoft.com/en-us/dotnet/api/system.net.decompressionmethods?view=net-8.0) | Only if the handler `AutomaticDecompression` is set to `All` (not the default!) |
| Go | net/http | Yes | [link](https://webscraping.ai/faq/go/how-do-i-process-compressed-http-responses-in-go) | Only gzip is supported. Ensure `DisableCompression` is false (default) on the transport. |
| Java | OkHttp | Yes | [link](https://medium.com/tech-insider/okhttps-gzip-compression-904919638458) | |
| PHP | Guzzle | Yes | [link](https://docs.guzzlephp.org/en/stable/request-options.html#decode-content) | Does NOT add the accept encoding header automatically. |
| Python | HTTPX | Yes | None | Couldn't find any source, but tested with 0.27.0 and httpbin |
| TypeScript/JavaScript | fetch | Yes | [link](https://stackoverflow.com/questions/70092469/node-fetch-automatic-gzip-decompression/78779242#78779242) | Automatically adds the accept encoding header and decompresses the response. Make sure `compress` is set to `true` (default) in the request options. |

## Example

Expand Down