Handle zlib on Ubuntu.
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void ExampleHttps() {
|
|||||||
// "Connection: Close" header in the response.
|
// "Connection: Close" header in the response.
|
||||||
// Both Google and GitHub support persistent connection but they don't like
|
// Both Google and GitHub support persistent connection but they don't like
|
||||||
// to include "Connection: Keep-Alive" header in the responses.
|
// to include "Connection: Keep-Alive" header in the responses.
|
||||||
//
|
//
|
||||||
// ExampleKeepAlive("http://httpbin.org/get");
|
// ExampleKeepAlive("http://httpbin.org/get");
|
||||||
// ExampleKeepAlive("https://www.boost.org/LICENSE_1_0.txt");
|
// ExampleKeepAlive("https://www.boost.org/LICENSE_1_0.txt");
|
||||||
// ExampleKeepAlive("https://www.google.com");
|
// ExampleKeepAlive("https://www.google.com");
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ bool HttpParser::ParseHeaderLine(const std::string& line) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Replace `!chunked_` with <TransferEncodingParsed>.
|
// TODO: Replace `!chunked_` with <TransferEncodingParsed>.
|
||||||
if (!chunked_ && !content_length_parsed_) {
|
if (!chunked_ && !content_length_parsed_) {
|
||||||
if (boost::iequals(name, http::headers::kTransferEncoding)) {
|
if (boost::iequals(name, http::headers::kTransferEncoding)) {
|
||||||
@@ -218,7 +218,7 @@ bool HttpParser::ParseChunkedContent() {
|
|||||||
Finish();
|
Finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_size_ + 2 <= pending_data_.size()) { // +2 for CRLF
|
if (chunk_size_ + 2 <= pending_data_.size()) { // +2 for CRLF
|
||||||
AppendContent(pending_data_.c_str(), chunk_size_);
|
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
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user