Supporting HTTP Compression
As far as I can tell there is currently no support for HTTP compression in neither the WinHTTP Client (WinHTTP itself doesn't seem to support it either, whereas WinInet does) nor the Boost ASIO Client. I'm looking into the possibility of adding support. Before I start I want to get some guidance on which external dependencies you would advise/accept.
The 2 immediate options are using zlib directly or using a C++ wrapper like boost::iostreams::gzip. The ASIO based client is clearly already strongly dependent on Boost, but would it be a problem to add a dependency for the Windows code (I would obviously like to share a common decompression component between the 2 impls)? Maybe there are other options apart from a zlib based approach?
Thanks, Chris
I think taking the zlib-based approach is the best option, with a build flag to disable it. Zlib is extremely non-intrusive and lightweight; I'd prefer depending on that over boost when possible.
Plus, we already depend on it via OpenSSL on all platforms (when building websockets).
This would be a great feature. I've used Boost to compress the body contents of POSTs prior to sending the request, and added the appropriate content-encoding header. and that seems to work as well.
Ok great. @ras0219-msft I'll use zlib directly. Are there existing cases where a feature is optionally included based on a compile time flag. I'd like to make sure I'm following the right pattern across the different build systems.
@samhatchett my primary use case is supporting retrieving compressed content and decompressing. But if I have time I'll add support for sending compressed content as well.
I think for now it would be best to tie it to the CPPREST_EXCLUDE_WEBSOCKETS flag to maintain the possibility of dependency-free builds on Windows, even though that seems really misleading right now.
The flag probably needs to be renamed something more like CPPREST_NO_DEPENDENCIES_ON_WINDOWS in the future, since that's what it's actually used for most of the time; I doubt anyone is building with that flag on Linux/OSX.
Ok, sounds good. What's the best way to add zlib as a dependency?
Options as I see them are:
- Add https://github.com/madler/zlib as a git submodule, and conditionally build it from source.
- Bundle the source within the Casablanca repo, and conditionally build it from source.
- Bundle the (very small) required binaries within the Casablanca repo.
- Require the consumer to provide the dynamic libraries themselves if they choose to enable the feature.
If we go with 4 it would probably make sense to use a dedicated compilation flag to enable it.
You missed an option: What about Nuget? I would be very surprised if it is not available on there.
GR
Sent from my Nexus 5.
On 28 Aug 2016 10:16 p.m., "deeringc" [email protected] wrote:
Ok, sounds good. What's the best way to add zlib as a dependency?
Options as I see them are:
- Add https://github.com/madler/zlib as a git submodule, and conditionally build it from source.
- Bundle the source within the Casablanca repo, and conditionally build it from source.
- Bundle the (very small) required binaries within the Casablanca repo.
- Require the consumer to provide the dynamic libraries themselves if they choose to enable the feature.
If we go with 4 it would probably make sense to use a dedicated compilation flag to enable it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/cpprestsdk/issues/226#issuecomment-242999942, or mute the thread https://github.com/notifications/unsubscribe-auth/AEy9nGMvrSHq7ICg30ci0T3c2cqcdXBWks5qkfqugaJpZM4JrWX8 .
Not an option for OSX I'm afraid.
Should this issue be closed? The feature seems available since 21 Oct 2017:
https://github.com/Microsoft/cpprestsdk/releases/tag/v2.10.0 "PR https://github.com/Microsoft/cpprestsdk/pull/233 adds compression support (deflate and gzip) for Windows Desktop and ASIO http_clients based on Zlib."
Yep, thanks!
Is the compression support for http_client compiled by default or we need to enable it? Thanks.
How to use request compression/decompression: https://github.com/microsoft/cpprestsdk/blob/96e7d20e398b629de2935f9ac32cfa2780cd0b0b/Release/tests/functional/http/client/outside_tests.cpp#L65-L89