Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a48c83

Browse files
committed
Updated project to use the uri submodule; updated some code in order to handle the new changes.
1 parent1ef781f commit8a48c83

File tree

48 files changed

+124
-3284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+124
-3284
lines changed

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "deps/gtest"]
22
path=deps/gtest
33
url=git://github.com/cpp-netlib/gtest
4+
[submodule "uri"]
5+
path=uri
6+
url=git://github.com/cpp-netlib/uri

‎CMakeLists.txt‎

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,15 @@ endif()
6868
message("C++ Compiler ID:${CMAKE_CXX_COMPILER_ID}")
6969
message("C++ Flags:${CMAKE_CXX_FLAGS} link flags:${CMAKE_CXX_LINK_FLAGS}")
7070
if (Boost_FOUND)
71-
if (MSVC)
72-
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
73-
endif(MSVC)
74-
if (WIN32)
75-
add_definitions(-D_WIN32_WINNT=0x0501)
76-
endif(WIN32)
77-
include_directories(${Boost_INCLUDE_DIRS})
78-
if(CPP-NETLIB_BUILD_TESTS)
79-
enable_testing()
80-
endif()
81-
#add_subdirectory(libs/network/src)
82-
if(CPP-NETLIB_BUILD_TESTS)
83-
enable_testing()
84-
#add_subdirectory(libs/network/test)
85-
if (NOTMSVC)
86-
#add_subdirectory(libs/mime/test)
87-
endif(NOTMSVC)
88-
endif()
89-
if(CPP-NETLIB_BUILD_EXAMPLES)
90-
#add_subdirectory(libs/network/example)
91-
endif()
71+
if (MSVC)
72+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
73+
endif(MSVC)
74+
if (WIN32)
75+
add_definitions(-D_WIN32_WINNT=0x0501)
76+
endif(WIN32)
77+
include_directories(${Boost_INCLUDE_DIRS})
9278
endif(Boost_FOUND)
9379

94-
if(CPP-NETLIB_BUILD_TESTS)
95-
enable_testing()
96-
endif()
97-
9880
message(STATUS"CPP-NETLIB Options selected:")
9981
message(STATUS" CPP-NETLIB_BUILD_SHARED_LIBS: ${CPP-NETLIB_BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
10082
message(STATUS" CPP-NETLIB_BUILD_TESTS: ${CPP-NETLIB_BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
@@ -107,6 +89,17 @@ message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(
10789
# The code following this point is for the new directory structure
10890
#
10991

92+
if(CPP-NETLIB_BUILD_TESTS)
93+
enable_testing()
94+
add_subdirectory(deps/gtest)
95+
set(GTEST_ROOT ${CPP-NETLIB_SOURCE_DIR}/deps/gtest)
96+
set(GTEST_FOUNDON)
97+
set(GTEST_INCLUDE_DIRS${GTEST_ROOT}/include)
98+
set(GTEST_LIBRARIES gtest)
99+
set(GTEST_MAIN_LIBRARIES gtest_main)
100+
set(GTEST_BOTH_LIBRARIES${GTEST_LIBRARIES}${GTEST_MAIN_LIBRARIES})
101+
endif()
102+
110103
add_subdirectory(uri)
111104
add_subdirectory(message)
112105
add_subdirectory(logging)

‎contrib/http_examples/CMakeLists.txt‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
add_executable(simple_wget simple_wget.cpp)
2121
add_executable(atom_reader atom/atom.cpp atom/main.cpp)
2222
add_executable(rss_reader rss/rss.cpp rss/main.cpp)
23-
add_executable(twitter_search twitter/search.cpp)
23+
#add_executable(twitter_search twitter/search.cpp)
2424
#add_executable(hello_world_server http/hello_world_server.cpp)
2525
add_executable(hello_world_client http/hello_world_client.cpp)
2626
#if (UNIX)
@@ -81,19 +81,19 @@ target_link_libraries(rss_reader
8181
cppnetlib-http-client-connections
8282
${CPP-NETLIB_LOGGING_LIB})
8383

84-
target_link_libraries(twitter_search
85-
${BOOST_CLIENT_LIBS}
86-
${CMAKE_THREAD_LIBS_INIT}
87-
cppnetlib-uri
88-
cppnetlib-message
89-
cppnetlib-message-directives
90-
cppnetlib-message-wrappers
91-
cppnetlib-http-message-wrappers
92-
cppnetlib-http-message
93-
cppnetlib-constants
94-
cppnetlib-http-client
95-
cppnetlib-http-client-connections
96-
${CPP-NETLIB_LOGGING_LIB})
84+
#target_link_libraries(twitter_search
85+
# ${BOOST_CLIENT_LIBS}
86+
# ${CMAKE_THREAD_LIBS_INIT}
87+
# cppnetlib-uri
88+
# cppnetlib-message
89+
# cppnetlib-message-directives
90+
# cppnetlib-message-wrappers
91+
# cppnetlib-http-message-wrappers
92+
# cppnetlib-http-message
93+
# cppnetlib-constants
94+
# cppnetlib-http-client
95+
# cppnetlib-http-client-connections
96+
# ${CPP-NETLIB_LOGGING_LIB})
9797

9898
#target_link_libraries(hello_world_server
9999
# ${BOOST_SERVER_LIBS}
@@ -120,7 +120,7 @@ if (OPENSSL_FOUND)
120120
target_link_libraries(simple_wget${OPENSSL_LIBRARIES})
121121
target_link_libraries(atom_reader${OPENSSL_LIBRARIES})
122122
target_link_libraries(rss_reader${OPENSSL_LIBRARIES})
123-
target_link_libraries(twitter_search${OPENSSL_LIBRARIES})
123+
#target_link_libraries(twitter_search ${OPENSSL_LIBRARIES})
124124
#target_link_libraries(hello_world_server ${OPENSSL_LIBRARIES})
125125
target_link_libraries(hello_world_client${OPENSSL_LIBRARIES})
126126
endif (OPENSSL_FOUND)
@@ -136,7 +136,7 @@ endif (OPENSSL_FOUND)
136136
set_target_properties(simple_wget PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
137137
set_target_properties(atom_reader PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
138138
set_target_properties(rss_reader PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
139-
set_target_properties(twitter_search PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
139+
#set_target_properties(twitter_search PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
140140
#set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
141141
set_target_properties(hello_world_client PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
142142
#if (UNIX)

‎contrib/http_examples/simple_wget.cpp‎

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,43 @@ namespace http = network::http;
2727

2828
namespace {
2929
std::stringget_filename(const network::uri &url) {
30-
std::string path =network::path(url);
31-
std::size_t index = path.find_last_of('/');
32-
std::string filename = path.substr(index +1);
30+
auto path = url.path();
31+
if (path) {
32+
auto path_str =std::string(*path);
33+
auto index = path_str.find_last_of('/');
34+
auto filename = path_str.substr(index +1);
3335
return filename.empty()?"index.html" : filename;
36+
}
37+
return"index.html";
3438
}
3539
}// namespace
3640

3741

3842
int
3943
main(int argc,char *argv[]) {
4044

41-
if (argc !=2) {
42-
std::cerr <<"Usage:" << argv[0] <<" url" << std::endl;
43-
return1;
44-
}
45+
if (argc !=2) {
46+
std::cerr <<"Usage:" << argv[0] <<" url" << std::endl;
47+
return1;
48+
}
4549

46-
try {
47-
http::client client;
48-
http::client::requestrequest(argv[1]);
49-
http::client::response response = client.get(request);
50+
try {
51+
http::client client;
52+
http::client::requestrequest(argv[1]);
53+
http::client::response response = client.get(request);
5054

51-
network::uri uri;
52-
request.get_uri(uri);
53-
std::string filename =get_filename(uri);
54-
std::cout <<"Saving to:" << filename << std::endl;
55-
std::ofstreamofs(filename.c_str());
56-
ofs <<static_cast<std::string>(body(response)) << std::endl;
57-
}
58-
catch (std::exception &e) {
59-
std::cerr << e.what() << std::endl;
60-
return1;
61-
}
55+
network::uri uri;
56+
request.get_uri(uri);
57+
std::string filename =get_filename(uri);
58+
std::cout <<"Saving to:" << filename << std::endl;
59+
std::ofstreamofs(filename.c_str());
60+
ofs <<static_cast<std::string>(body(response)) << std::endl;
61+
}
62+
catch (std::exception &e) {
63+
std::cerr << e.what() << std::endl;
64+
return1;
65+
}
6266

63-
return0;
67+
return0;
6468
}
6569
//]

‎contrib/http_examples/twitter/search.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ int main(int argc, char *argv[]) {
2929
network::uribase_uri("http://search.twitter.com/search.json");
3030

3131
std::cout <<"Searching Twitter for query:" << argv[1] << std::endl;
32-
network::uri search;
33-
search << base_uri <<network::query("q",network::encoded(argv[1]));
34-
http::client::requestrequest(search);
32+
33+
network::uri_builderbuilder(base_uri);
34+
builder.query("q", argv[1]))
35+
http::client::requestrequest(builder.uri());
3536
http::client::response response = client.get(request);
3637

3738
Document d;

‎http/src/network/protocol/http/algorithms/linearize.hpp‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include<network/constants.hpp>
1515
#include<boost/concept/requires.hpp>
1616
#include<boost/optional.hpp>
17+
#include<boost/lexical_cast.hpp>
1718
#include<boost/range/algorithm/copy.hpp>
1819

1920
namespacenetwork {
@@ -38,8 +39,8 @@ struct linearize_header {
3839
typedef std::ostringstream output_stream;
3940
typedef constants consts;
4041
output_stream header_line;
41-
header_line <<name(header)
42-
<<consts::colon() <<consts::space()
42+
header_line <<name(header)
43+
<<consts::colon() <<consts::space()
4344
<<value(header) <<consts::crlf();
4445
return header_line.str();
4546
}
@@ -50,16 +51,16 @@ BOOST_CONCEPT_REQUIRES(
5051
((ClientRequest<Request>)),
5152
(OutputIterator)
5253
) linearize(
53-
Requestconst & request,
54+
Requestconst & request,
5455
std::stringconst & method,
55-
unsigned version_major,
56-
unsigned version_minor,
56+
unsigned version_major,
57+
unsigned version_minor,
5758
OutputIterator oi
58-
)
59+
)
5960
{
6061
typedef constants consts;
6162
typedef std::string string_type;
62-
static string_type
63+
static string_type
6364
http_slash =consts::http_slash()
6465
, accept =consts::accept()
6566
, accept_mime =consts::default_accept_mime()
@@ -76,7 +77,7 @@ BOOST_CONCEPT_REQUIRES(
7677
*oi =consts::space_char();
7778
{
7879
std::string path_ =path(request);
79-
if (path_.empty() || path_[0] !=consts::slash_char())
80+
if (path_.empty() || path_[0] !=consts::slash_char())
8081
*oi =consts::slash_char();
8182
boost::copy(path_, oi);
8283
}
@@ -156,8 +157,8 @@ BOOST_CONCEPT_REQUIRES(
156157
auto body_data =network::body(request);
157158
returnstd::copy(body_data.begin(), body_data.end(), oi);
158159
}
159-
160+
160161
}// namespace http
161162
}// namespace network
162-
163+
163164
#endif/* NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028*/

‎http/src/network/protocol/http/client/connection/simple_connection_factory.ipp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include<network/uri/uri_io.hpp>
1919
#endif
2020
#include<boost/algorithm/string/case_conv.hpp>
21+
#include<boost/algorithm/string/predicate.hpp>
2122

2223
#include<network/protocol/http/message/wrappers/uri.hpp>
2324

@@ -39,7 +40,7 @@ struct simple_connection_factory_pimpl {
3940
NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)");
4041
::network::uri uri_ =http::uri(request);
4142
NETWORK_MESSAGE("destination:" << uri_);
42-
bool https =boost::algorithm::to_lower_copy(::network::scheme(uri_)) =="https";
43+
bool https =boost::algorithm::to_lower_copy(std::string(*uri_.scheme())) =="https";
4344
return std::make_shared<http_async_connection>(
4445
res_delegate_factory_->create_resolver_delegate(service, options.cache_resolved()),
4546
conn_delegate_factory_->create_connection_delegate(service, https, options),

‎http/src/network/protocol/http/client/facade.ipp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include<network/protocol/http/client/facade.hpp>
1111
#include<network/detail/debug.hpp>
12+
#include<boost/lexical_cast.hpp>
1213

1314
namespacenetwork {
1415
namespacehttp {

‎http/src/network/protocol/http/message/wrappers/anchor.ipp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ anchor_wrapper::anchor_wrapper(request_base const & request)
2020
anchor_wrapper::operatorstd::string ()const {
2121
::network::uri uri_;
2222
request_.get_uri(uri_);
23-
returnfragment(uri_);
23+
auto fragment = uri_.fragment();
24+
return fragment?std::string(*fragment) :std::string();
2425
}
2526

2627
}// namespace http

‎http/src/network/protocol/http/message/wrappers/host.ipp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ host_wrapper::host_wrapper(request_base const & request)
1818
host_wrapper::operatorstd::string ()const {
1919
::network::uri uri_;
2020
request_.get_uri(uri_);
21-
returnhost(uri_);
21+
auto host = uri_.host();
22+
return host?std::string(*host) :std::string("");
2223
}
2324

2425
}// namespace http

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp