Skip to content

Enable HTTP compression support on all platforms #1322

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

Merged
merged 3 commits into from
Feb 21, 2020

Conversation

KindDragon
Copy link
Contributor

@KindDragon KindDragon commented Feb 5, 2020

You can set CPPREST_EXCLUDE_COMPRESSION=ON to disable compression

Fix #1165

#define CPPREST_HTTP_COMPRESSION
#endif // !defined(CPPREST_EXCLUDE_COMPRESSION)
#endif // defined(TARGET_OS_MAC)
#elif defined(_WIN32) && (!defined(WINAPI_FAMILY) || WINAPI_PARTITION_DESKTOP)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This condition always returns true, because if WINAPI_FAMILY is defined, then WINAPI_PARTITION_DESKTOP is just a constant.
Perhaps the author wanted to write WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP), but I do not know why this condition is necessary since UWP applications should also work

@@ -17,18 +17,9 @@
// it. CPPREST_EXCLUDE_BROTLI is set if we want to explicitly disable Brotli compression support.
// CPPREST_EXCLUDE_WEBSOCKETS is a flag that now essentially means "no external dependencies". TODO: Rename

#if __APPLE__
#include "TargetConditionals.h"
#if defined(TARGET_OS_MAC)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I googled correctly, TARGET_OS_MAC includes all Apple platforms https://stackoverflow.com/a/49560690
I don't know why we need this condition either

@KindDragon
Copy link
Contributor Author

Related to PR #964 (just found it)

@KindDragon
Copy link
Contributor Author

On Ubuntu 16:
../Release/tests/functional/http/client/compression_tests.cpp:379: error: Failure in compress_and_decompress_GZIP: Unhandled exception: Unrecoverable decompression stream error -3 FAILED
Test case compression_tests:compress_and_decompress_GZIP FAILED
Starting test case compression_tests:compress_and_decompress_DEFLATE...
Test case compression_tests:compress_and_decompress_DEFLATE PASSED
Starting test case compression_tests:compress_and_decompress_BROTLI...
Test case compression_tests:compress_and_decompress_BROTLI PASSED

@KindDragon KindDragon force-pushed the patch-1 branch 6 times, most recently from fd62468 to 5c4ff82 Compare February 6, 2020 09:51
@KindDragon KindDragon changed the title Enable compression on all platform where Enable compression on all platform Feb 6, 2020
@KindDragon KindDragon changed the title Enable compression on all platform Enable Http compression on all platform Feb 6, 2020
mkdir build.debug
cd build.debug
/usr/local/bin/cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ..
/usr/local/bin/cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCPPREST_EXCLUDE_COMPRESSION=ON ..
Copy link
Member

Choose a reason for hiding this comment

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

Is this not a serious breaking change?

@BillyONeal
Copy link
Member

To clarify: the feature is turned off because tests fail; I don't believe turning the feature on in code, and then disabling all testing of it, is an acceptable change. If you can debug into it and fix it so that tests pass for the platforms on which you're enabling the feature, then of course we'd be happy to merge that, but I don't think I can merge this in this form.

Arkadii Shapkin and others added 2 commits February 21, 2020 00:59
To can set CPPREST_EXCLUDE_COMPRESSION=ON to disable compression
@KindDragon
Copy link
Contributor Author

KindDragon commented Feb 20, 2020

Hi. I installed Ubuntu 16 and checked, this issue only happens with zlib 1.2.8. zlib 1.2.9 and better works well. Test uri_address.compress_and_decompress_gzip failing only with tuples {16001, 8192}..{263456, 256 * 1024} and parameter compressible=true. inflate function somehow just return error Z_DATA_ERROR (msg "invalid distance too far back") on second chunk.
Maybe we just set the requirement to zlib 1.2.9 when compression enabled?

@KindDragon
Copy link
Contributor Author

Found on the web similar issue https://npm.community/t/zlib-invalid-distance-too-far-back/5577

@BillyONeal
Copy link
Member

Then I think we need some form of detection for those to turn the feature off for those versions; we can't merge something that causes tests to fail in a supported configuration.

@KindDragon
Copy link
Contributor Author

KindDragon commented Feb 21, 2020

I spent a couple of hours, but found out why it didn't work with 1.2.8
One line fix... Vacation time well spent :)

@BillyONeal
Copy link
Member

Awesome, thanks for your contribution!

@BillyONeal BillyONeal changed the title Enable Http compression on all platform Enable HTTP compression support on all platforms Feb 21, 2020
@BillyONeal BillyONeal merged commit 1f97f54 into microsoft:master Feb 21, 2020
@KindDragon KindDragon deleted the patch-1 branch February 22, 2020 20:29
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.

Compression support on Linux
2 participants