Handle zlib on Ubuntu.

master
Chunting Gu 6 years ago
parent 5f64f3bb62
commit bc586c3ea0

@ -117,6 +117,11 @@ if(WIN32)
# For including CMake generated zconf.h. # For including CMake generated zconf.h.
include_directories(${PROJECT_BINARY_DIR}/third_party/src/zlib) include_directories(${PROJECT_BINARY_DIR}/third_party/src/zlib)
else()
find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
endif() endif()
# SOAP support needs pugixml to parse and create XML. # SOAP support needs pugixml to parse and create XML.

@ -5,6 +5,8 @@ set(EXAMPLE_COMMON_LIBS webcc ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
"${CMAKE_THREAD_LIBS_INIT}") "${CMAKE_THREAD_LIBS_INIT}")
if(WIN32) if(WIN32)
set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} zlibstatic crypt32) set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} zlibstatic crypt32)
else()
set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} ${ZLIB_LIBRARIES})
endif() endif()
if(UNIX) if(UNIX)

@ -117,7 +117,8 @@ int main() {
// Note that the exception handling is mandatory. // Note that the exception handling is mandatory.
try { try {
ExampleBasic(); // ExampleBasic();
ExampleCompression();
} catch (const Exception& e) { } catch (const Exception& e) {
std::cout << "Exception: " << e.what() << std::endl; std::cout << "Exception: " << e.what() << std::endl;

@ -300,7 +300,7 @@ bool HttpParser::Finish() {
// Also see: https://stackoverflow.com/questions/5280633/gzip-compression-of-chunked-encoding-response // Also see: https://stackoverflow.com/questions/5280633/gzip-compression-of-chunked-encoding-response
std::string decompressed; std::string decompressed;
if (!Decompress(content_, decompressed)) { if (!Decompress(content_, decompressed)) {
LOG_ERRO("Cannot decompress the HTTP content!", ); LOG_ERRO("Cannot decompress the HTTP content!");
return false; return false;
} }

Loading…
Cancel
Save