From d51d6e4205b83704c5e206a1b647aa16bc49036e Mon Sep 17 00:00:00 2001 From: 3noch Date: Tue, 22 Jan 2013 14:39:53 -0500 Subject: [PATCH 1/4] Add needed Boost libs and OpenSSL headers to CMake config --- CMakeLists.txt | 7 ++++++- libs/network/example/CMakeLists.txt | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4667f235f..3d176a521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 2.8) project(CPP-NETLIB) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTI_THREADED ON) -find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options ) +find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options chrono ) find_package( OpenSSL ) find_package( Threads ) set(CMAKE_VERBOSE_MAKEFILE true) @@ -18,6 +18,7 @@ endif() if (OPENSSL_FOUND) add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS) + include_directories(${OPENSSL_INCLUDE_DIR}) endif() if (Boost_FOUND) @@ -37,4 +38,8 @@ if (Boost_FOUND) add_subdirectory(libs/network/example) endif(Boost_FOUND) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +endif() + enable_testing() diff --git a/libs/network/example/CMakeLists.txt b/libs/network/example/CMakeLists.txt index 20ab9acaf..ce2eadd35 100644 --- a/libs/network/example/CMakeLists.txt +++ b/libs/network/example/CMakeLists.txt @@ -28,13 +28,17 @@ set(BOOST_CLIENT_LIBS ${Boost_THREAD_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_REGEX_LIBRARY} - ${Boost_SYSTEM_LIBRARY}) + ${Boost_SYSTEM_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_CHRONO_LIBRARY}) set(BOOST_SERVER_LIBS ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY}) + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_CHRONO_LIBRARY}) target_link_libraries(http_client ${BOOST_CLIENT_LIBS} From 16cf0935013e6596e889ffd22a12bf231cf1a498 Mon Sep 17 00:00:00 2001 From: 3noch Date: Tue, 22 Jan 2013 15:16:30 -0500 Subject: [PATCH 2/4] Provide source port as part of the request --- boost/network/protocol/http/impl/request.hpp | 2 ++ boost/network/protocol/http/server/sync_connection.hpp | 1 + libs/network/example/http/hello_world_server.cpp | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/boost/network/protocol/http/impl/request.hpp b/boost/network/protocol/http/impl/request.hpp index 5ba92d6c1..1ab6bb912 100644 --- a/boost/network/protocol/http/impl/request.hpp +++ b/boost/network/protocol/http/impl/request.hpp @@ -157,6 +157,7 @@ namespace http { typedef vector_type headers_container_type; typedef boost::uint16_t port_type; mutable string_type source; + mutable port_type source_port; mutable string_type method; mutable string_type destination; mutable boost::uint8_t http_version_major; @@ -168,6 +169,7 @@ namespace http { using std::swap; swap(method, r.method); swap(source, r.source); + swap(source_port, r.source_port); swap(destination, r.destination); swap(http_version_major, r.http_version_major); swap(http_version_minor, r.http_version_minor); diff --git a/boost/network/protocol/http/server/sync_connection.hpp b/boost/network/protocol/http/server/sync_connection.hpp index 32d562b93..121f5b3cd 100644 --- a/boost/network/protocol/http/server/sync_connection.hpp +++ b/boost/network/protocol/http/server/sync_connection.hpp @@ -79,6 +79,7 @@ namespace boost { namespace network { namespace http { void handle_read_headers(boost::system::error_code const &ec, size_t bytes_transferred) { if (!ec) { request_.source = socket_.remote_endpoint().address().to_string(); + request_.source_port = socket_.remote_endpoint().port(); boost::tribool done; buffer_type::iterator new_start; tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred); diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index e6ec08bcf..e515f2cf4 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -29,8 +29,9 @@ struct hello_world { void operator() (server::request const &request, server::response &response) { server::string_type ip = source(request); + unsigned int port = request.source_port; std::ostringstream data; - data << "Hello, " << ip << "!"; + data << "Hello, " << ip << ':' << port << '!'; response = server::response::stock_reply( server::response::ok, data.str()); } From c0570dd24634420803c37586a3e4014801a8f5f9 Mon Sep 17 00:00:00 2001 From: 3noch Date: Tue, 22 Jan 2013 15:23:57 -0500 Subject: [PATCH 3/4] Fix spacing --- libs/network/example/http/hello_world_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index e515f2cf4..5e925e911 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -29,7 +29,7 @@ struct hello_world { void operator() (server::request const &request, server::response &response) { server::string_type ip = source(request); - unsigned int port = request.source_port; + unsigned int port = request.source_port; std::ostringstream data; data << "Hello, " << ip << ':' << port << '!'; response = server::response::stock_reply( From 26c681bb6c76134b11df18c3974a54f9b68bd050 Mon Sep 17 00:00:00 2001 From: 3noch Date: Wed, 23 Jan 2013 11:51:43 -0500 Subject: [PATCH 4/4] Revert "Merge pull request #1 from CovenantEyes/ce-custom" This reverts commit ac45ccdb0d917f7cb9bfd3ada77e5398dffec358, reversing changes made to d51d6e4205b83704c5e206a1b647aa16bc49036e. --- boost/network/protocol/http/impl/request.hpp | 2 -- boost/network/protocol/http/server/sync_connection.hpp | 1 - libs/network/example/http/hello_world_server.cpp | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/boost/network/protocol/http/impl/request.hpp b/boost/network/protocol/http/impl/request.hpp index 1ab6bb912..5ba92d6c1 100644 --- a/boost/network/protocol/http/impl/request.hpp +++ b/boost/network/protocol/http/impl/request.hpp @@ -157,7 +157,6 @@ namespace http { typedef vector_type headers_container_type; typedef boost::uint16_t port_type; mutable string_type source; - mutable port_type source_port; mutable string_type method; mutable string_type destination; mutable boost::uint8_t http_version_major; @@ -169,7 +168,6 @@ namespace http { using std::swap; swap(method, r.method); swap(source, r.source); - swap(source_port, r.source_port); swap(destination, r.destination); swap(http_version_major, r.http_version_major); swap(http_version_minor, r.http_version_minor); diff --git a/boost/network/protocol/http/server/sync_connection.hpp b/boost/network/protocol/http/server/sync_connection.hpp index 121f5b3cd..32d562b93 100644 --- a/boost/network/protocol/http/server/sync_connection.hpp +++ b/boost/network/protocol/http/server/sync_connection.hpp @@ -79,7 +79,6 @@ namespace boost { namespace network { namespace http { void handle_read_headers(boost::system::error_code const &ec, size_t bytes_transferred) { if (!ec) { request_.source = socket_.remote_endpoint().address().to_string(); - request_.source_port = socket_.remote_endpoint().port(); boost::tribool done; buffer_type::iterator new_start; tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred); diff --git a/libs/network/example/http/hello_world_server.cpp b/libs/network/example/http/hello_world_server.cpp index 5e925e911..e6ec08bcf 100644 --- a/libs/network/example/http/hello_world_server.cpp +++ b/libs/network/example/http/hello_world_server.cpp @@ -29,9 +29,8 @@ struct hello_world { void operator() (server::request const &request, server::response &response) { server::string_type ip = source(request); - unsigned int port = request.source_port; std::ostringstream data; - data << "Hello, " << ip << ':' << port << '!'; + data << "Hello, " << ip << "!"; response = server::response::stock_reply( server::response::ok, data.str()); }