-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[All languages] Support for gzip compression #3365
Comments
I saw your proposal in OAI/OpenAPI-Specification#738 For the time being, we can use To support it, it comes down to the HTTP libraries used in the API clients (whether it has a switch/flag to easily support gzip or other content encodings). |
added gzip support for both the jaxrs-cxf (server) and to the jaxrs-cxf client in PR #4003 + documented the supported gzip feature using interface GzipFeatures. |
It would be very helpful for the client using mobiles. Saving mobile data and increase speed can improve UX a lot. |
* Fix for issue 3365 for Java * Added tests * Convert CRLF to LF * Convert CRLF to LF in tests
…wagger-api#4967) * Fix for issue 3365 for Java * Added tests * Convert CRLF to LF * Convert CRLF to LF in tests
Description
This is a feature request for two options enabling support for gzip compression for the generated API clients for all languages.
The first option would enable support for compression in API requests. When this option is turned on, the client would:
Content-Encoding: gzip
to the HTTP request headersThe second option would enable support for compression in API responses. When this option is turned on, the client would:
Accept-Encoding: gzip
to the HTTP request headersContent-Encoding: gzip
Ideally, both options would be on by default.
Related issues
#3279 discusses how to add gzip support to the Java API.
Suggest a Fix
For some languages, this won't be possible. For example, the JavaScript API presumably uses XmlHttpRequest behind the scenes when running in the browser, and the spec won't let you set encoding-related headers.
For other languages, though, this should be fairly straightforward. For example, in Java, adding support for GZIP compression for API requests and responses in the Jersey 1.x client consists of simply adding:
client.addFilter(new GZIPContentEncodingFilter());
to the
rebuildHttpClient
function in ApiClient.java. Passing in the parameterfalse
to the constructor would enable it only for responses. Simply encapsulate this behaviour behind a couple of properties and you're done!The text was updated successfully, but these errors were encountered: