diff --git a/CMakeLists.txt b/CMakeLists.txt index 39cd96c..a87b232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,11 @@ if(WIN32) # For including CMake generated zconf.h. include_directories(${PROJECT_BINARY_DIR}/third_party/src/zlib) +else() + find_package(ZLIB REQUIRED) + if(ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIRS}) + endif() endif() # SOAP support needs pugixml to parse and create XML. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 92a9231..6c6e8f0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,6 +5,8 @@ set(EXAMPLE_COMMON_LIBS webcc ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} "${CMAKE_THREAD_LIBS_INIT}") if(WIN32) set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} zlibstatic crypt32) +else() + set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} ${ZLIB_LIBRARIES}) endif() if(UNIX) diff --git a/examples/http_client.cc b/examples/http_client.cc index 2945b3c..c0ee859 100644 --- a/examples/http_client.cc +++ b/examples/http_client.cc @@ -78,7 +78,7 @@ void ExampleHttps() { // "Connection: Close" header in the response. // Both Google and GitHub support persistent connection but they don't like // to include "Connection: Keep-Alive" header in the responses. -// +// // ExampleKeepAlive("http://httpbin.org/get"); // ExampleKeepAlive("https://www.boost.org/LICENSE_1_0.txt"); // ExampleKeepAlive("https://www.google.com"); @@ -117,7 +117,8 @@ int main() { // Note that the exception handling is mandatory. try { - ExampleBasic(); + // ExampleBasic(); + ExampleCompression(); } catch (const Exception& e) { std::cout << "Exception: " << e.what() << std::endl; diff --git a/webcc/http_parser.cc b/webcc/http_parser.cc index 87add7f..d3c2bd7 100644 --- a/webcc/http_parser.cc +++ b/webcc/http_parser.cc @@ -154,7 +154,7 @@ bool HttpParser::ParseHeaderLine(const std::string& line) { break; } } - + // TODO: Replace `!chunked_` with . if (!chunked_ && !content_length_parsed_) { if (boost::iequals(name, http::headers::kTransferEncoding)) { @@ -218,7 +218,7 @@ bool HttpParser::ParseChunkedContent() { Finish(); return true; } - + if (chunk_size_ + 2 <= pending_data_.size()) { // +2 for CRLF AppendContent(pending_data_.c_str(), chunk_size_); @@ -300,7 +300,7 @@ bool HttpParser::Finish() { // Also see: https://stackoverflow.com/questions/5280633/gzip-compression-of-chunked-encoding-response std::string decompressed; if (!Decompress(content_, decompressed)) { - LOG_ERRO("Cannot decompress the HTTP content!", ); + LOG_ERRO("Cannot decompress the HTTP content!"); return false; }