Skip to content

Commit a938205

Browse files
committed
Merge pull request #42 from glynos/1.0-devel
1.0 devel
2 parents 98a44c8 + 2941b71 commit a938205

File tree

6 files changed

+60
-40
lines changed

6 files changed

+60
-40
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ if (Boost_FOUND)
1111
set(Boost_USE_STATIC_LIBS ON)
1212
set(Boost_USE_MULTI_THREADED ON)
1313
include_directories(${Boost_INCLUDE_DIRS})
14-
endif()
14+
endif(Boost_FOUND)
15+
if (MSVC)
16+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
17+
endif(MSVC)
18+
if (WIN32)
19+
add_definitions(-D_WIN32_WINNT=0x0501)
20+
endif(WIN32)
1521
enable_testing()
1622
add_subdirectory(libs/network/build)
1723
add_subdirectory(libs/network/test)
18-
add_subdirectory(libs/mime/test)
24+
if (NOT MSVC)
25+
add_subdirectory(libs/mime/test)
26+
endif(NOT MSVC)
1927
add_subdirectory(libs/network/example)
2028

boost/network/protocol/http/client/connection/sync_base.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace boost { namespace network { namespace http { namespace impl {
130130
}
131131
if (boost::iequals(boost::begin(transfer_encoding_range)->second, "chunked")) {
132132
bool stopping = false;
133-
do {
133+
do {
134134
std::size_t chunk_size_line = read_until(socket_, response_buffer, "\r\n", error);
135135
if ((chunk_size_line == 0) && (error != boost::asio::error::eof)) throw boost::system::system_error(error);
136136
std::size_t chunk_size = 0;
@@ -163,7 +163,7 @@ namespace boost { namespace network { namespace http { namespace impl {
163163

164164
if (chunk_size != 0)
165165
throw std::runtime_error("Size mismatch between tranfer encoding chunk data size and declared chunk size.");
166-
}
166+
}
167167
} while (!stopping);
168168
} else throw std::runtime_error("Unsupported Transfer-Encoding.");
169169
} else {
@@ -177,7 +177,7 @@ namespace boost { namespace network { namespace http { namespace impl {
177177
while ((bytes_read = boost::asio::read(socket_, response_buffer, boost::asio::transfer_at_least(1), error))) {
178178
body_stream << &response_buffer;
179179
length -= bytes_read;
180-
if ((length <= 0) or error)
180+
if ((length <= 0) || error)
181181
break;
182182
}
183183
}

boost/network/protocol/http/policies/pooled_connection.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace boost { namespace network { namespace http {
2929
typedef typename resolver_policy<Tag>::type resolver_base;
3030
typedef typename resolver_base::resolver_type resolver_type;
3131
typedef function<typename resolver_base::resolver_iterator_pair(resolver_type &, string_type const &, string_type const &)> resolver_function_type;
32-
32+
3333
void cleanup() {
3434
host_connection_map().swap(host_connections);
3535
}
@@ -84,9 +84,9 @@ namespace boost { namespace network { namespace http {
8484
pimpl->read_headers(response_, response_buffer);
8585

8686
if (
87-
get_body && response_.status() != 304
87+
get_body && response_.status() != 304
8888
&& (response_.status() != 204)
89-
&& not (response_.status() >= 100 && response_.status() <= 199)
89+
&& !(response_.status() >= 100 && response_.status() <= 199)
9090
) {
9191
pimpl->read_body(response_, response_buffer);
9292
}
@@ -124,7 +124,7 @@ namespace boost { namespace network { namespace http {
124124
};
125125

126126
typedef shared_ptr<connection_impl> connection_ptr;
127-
127+
128128
typedef unordered_map<string_type, connection_ptr> host_connection_map;
129129
host_connection_map host_connections;
130130
bool follow_redirect_;
@@ -163,7 +163,7 @@ namespace boost { namespace network { namespace http {
163163

164164
pooled_connection_policy(bool cache_resolved, bool follow_redirect)
165165
: resolver_base(cache_resolved), host_connections(), follow_redirect_(follow_redirect) {}
166-
166+
167167
};
168168

169169
} // namespace http

boost/network/protocol/http/policies/simple_connection.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ namespace boost { namespace network { namespace http {
2929
typedef function<typename resolver_base::resolver_iterator_pair(resolver_type &, string_type const &, string_type const &)> resolver_function_type;
3030

3131
struct connection_impl {
32-
connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & hostname, string_type const & port, resolver_function_type resolve, bool https, optional<string_type> const & certificate_filename = optional<string_type>(), optional<string_type> const & verify_path = optional<string_type>())
32+
connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & hostname, string_type const & port, resolver_function_type resolve, bool https, optional<string_type> const & certificate_filename = optional<string_type>(), optional<string_type> const & verify_path = optional<string_type>())
3333
: pimpl()
34-
, follow_redirect_(follow_redirect)
34+
, follow_redirect_(follow_redirect)
3535
{
3636
pimpl.reset(impl::sync_connection_base<Tag,version_major,version_minor>::new_connection(resolver, resolve, https, certificate_filename, verify_path));
3737
}
@@ -54,7 +54,7 @@ namespace boost { namespace network { namespace http {
5454
boost::uint16_t status = response_.status();
5555
if (status >= 300 && status <= 307) {
5656
typename headers_range<http::basic_response<Tag> >::type location_range = headers(response_)["Location"];
57-
typename range_iterator<typename headers_range<http::basic_request<Tag> >::type>::type location_header = boost::begin(location_range);
57+
typename range_iterator<typename headers_range<http::basic_response<Tag> >::type>::type location_header = boost::begin(location_range);
5858
if (location_header != boost::end(location_range)) {
5959
request_.uri(location_header->second);
6060
} else throw std::runtime_error("Location header not defined in redirect response.");
@@ -97,7 +97,7 @@ namespace boost { namespace network { namespace http {
9797

9898
void cleanup() { }
9999

100-
simple_connection_policy(bool cache_resolved, bool follow_redirect)
100+
simple_connection_policy(bool cache_resolved, bool follow_redirect)
101101
: resolver_base(cache_resolved), follow_redirect_(follow_redirect) {}
102102

103103
// member variables

libs/network/example/CMakeLists.txt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,40 @@
66
include_directories(${CPP-NETLIB_SOURCE_DIR})
77
find_package( Boost 1.41.0 COMPONENTS program_options system regex date_time thread filesystem )
88
find_package( OpenSSL )
9-
include_directories(${OPENSSL_INCLUDE_DIR})
109
find_package( Threads )
11-
set(Boost_USE_STATIC_LIBS ON)
12-
set(Boost_USE_MULTITHREADED ON)
10+
11+
if (Boost_FOUND)
12+
set(Boost_USE_STATIC_LIBS ON)
13+
set(Boost_USE_MULTITHREADED ON)
14+
endif (Boost_FOUND)
15+
16+
if (OPENSSL_FOUND)
17+
include_directories(${OPENSSL_INCLUDE_DIR})
18+
endif (OPENSSL_FOUND)
1319

1420
if (Boost_FOUND)
1521
add_executable(http_client http_client.cpp)
22+
add_dependencies(http_client cppnetlib-uri-parsers)
23+
target_link_libraries(http_client ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
24+
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
25+
1626
add_executable(simple_wget simple_wget.cpp)
27+
add_dependencies(simple_wget cppnetlib-uri-parsers)
28+
target_link_libraries(simple_wget ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
29+
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
30+
1731
add_executable(hello_world_server http/hello_world_server.cpp)
18-
add_executable(fileserver http/fileserver.cpp)
32+
target_link_libraries(hello_world_server ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
33+
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
34+
35+
if (UNIX)
36+
add_executable(fileserver http/fileserver.cpp)
37+
target_link_libraries(fileserver ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
38+
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
39+
endif (UNIX)
40+
1941
add_executable(uri uri.cpp)
20-
add_dependencies(http_client cppnetlib-uri-parsers)
21-
add_dependencies(simple_wget cppnetlib-uri-parsers)
2242
add_dependencies(uri cppnetlib-uri-parsers)
23-
target_link_libraries(http_client ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} cppnetlib-uri-parsers)
24-
target_link_libraries(simple_wget ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} cppnetlib-uri-parsers)
25-
target_link_libraries(hello_world_server ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} )
26-
target_link_libraries(fileserver ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
2743
target_link_libraries(uri cppnetlib-uri-parsers)
28-
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
29-
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
30-
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
31-
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
3244
set_target_properties(uri PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
3345
endif()

libs/network/test/http/http_test_server.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright Kim Grasman 2008.
33
// Distributed under the Boost Software License, Version 1.0.
44
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,14 +16,14 @@
1616
#include <windows.h>
1717

1818
// ShellExecuteEx
19-
#include <shellapi.h>
19+
#include <shellapi.h>
2020
#pragma comment( lib, "shell32" )
2121
#else
2222
#include <unistd.h> // fork, execlp etc.
2323
#include <sys/types.h>
2424
#include <sys/wait.h> // for waitpid
2525
#include <sys/stat.h> // for chmod
26-
#include <signal.h> // for kill
26+
#include <signal.h> // for kill
2727
#endif
2828

2929
struct http_test_server
@@ -61,7 +61,7 @@ struct http_test_server
6161
boost::filesystem::path get_server_path(const boost::filesystem::path& base_path) {
6262
using namespace boost::filesystem;
6363

64-
const path script_name =
64+
const path script_name =
6565
#if defined(HTTPS_SERVER_TEST)
6666
"https_test_server.py"
6767
#else
@@ -84,17 +84,17 @@ struct http_test_server
8484
script_handle_t launch_python_script(const boost::filesystem::path& python_script_path) {
8585
using namespace boost::filesystem;
8686

87-
path::string_type script_name = python_script_path.filename().string();
88-
path::string_type script_dir = python_script_path.parent_path().string();
87+
path::string_type script_name = python_script_path.filename().native();
88+
path::string_type script_dir = python_script_path.parent_path().native();
8989

9090
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
9191
SHELLEXECUTEINFOA sei = {0};
9292
sei.cbSize = sizeof(sei);
9393
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
9494
sei.lpVerb = "open";
9595
sei.lpFile = "python.exe";
96-
sei.lpParameters = script_name.c_str();
97-
sei.lpDirectory = script_dir.c_str();
96+
sei.lpParameters = reinterpret_cast<LPCSTR>(script_name.c_str());
97+
sei.lpDirectory = reinterpret_cast<LPCSTR>(script_dir.c_str());
9898
sei.nShow = SW_SHOWNOACTIVATE;
9999

100100
if (!ShellExecuteExA(&sei))
@@ -107,16 +107,16 @@ struct http_test_server
107107
if (child_process < 0)
108108
return false;
109109

110-
if (child_process == 0) {
110+
if (child_process == 0) {
111111
// child process
112-
112+
113113
// cd into script dir and launch python script
114114
current_path(script_dir);
115115

116116
if (execlp("python", "python", script_name.c_str(), (char*)NULL) == -1)
117117
return 0;
118-
}
119-
else {
118+
}
119+
else {
120120
// parent
121121
sleep(1);
122122
}

0 commit comments

Comments
 (0)