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

Restructure dirs#184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 5 commits intocpp-netlib:masterfromglynos:restructure_dirs
Jan 9, 2013
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Updated project to use the uri submodule; updated some code in order …
…to handle the new changes.
  • Loading branch information
@glynos
glynos committedJan 5, 2013
commit8a48c83ffa8e7386737bedc06bb93856ebcdac8c
3 changes: 3 additions & 0 deletions.gitmodules
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
[submodule "deps/gtest"]
path = deps/gtest
url = git://github.com/cpp-netlib/gtest
[submodule "uri"]
path = uri
url = git://github.com/cpp-netlib/uri
43 changes: 18 additions & 25 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,33 +68,15 @@ endif()
message("C++ Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
if (Boost_FOUND)
if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
if (WIN32)
add_definitions(-D_WIN32_WINNT=0x0501)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})
if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
endif()
#add_subdirectory(libs/network/src)
if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
#add_subdirectory(libs/network/test)
if (NOT MSVC)
#add_subdirectory(libs/mime/test)
endif(NOT MSVC)
endif()
if(CPP-NETLIB_BUILD_EXAMPLES)
#add_subdirectory(libs/network/example)
endif()
if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
if (WIN32)
add_definitions(-D_WIN32_WINNT=0x0501)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)

if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
endif()

message(STATUS "CPP-NETLIB Options selected:")
message(STATUS " CPP-NETLIB_BUILD_SHARED_LIBS: ${CPP-NETLIB_BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
message(STATUS " CPP-NETLIB_BUILD_TESTS: ${CPP-NETLIB_BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
Expand All@@ -107,6 +89,17 @@ message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(
# The code following this point is for the new directory structure
#

if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
add_subdirectory(deps/gtest)
set(GTEST_ROOT ${CPP-NETLIB_SOURCE_DIR}/deps/gtest)
set(GTEST_FOUND ON)
set(GTEST_INCLUDE_DIRS ${GTEST_ROOT}/include)
set(GTEST_LIBRARIES gtest)
set(GTEST_MAIN_LIBRARIES gtest_main)
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
endif()

add_subdirectory(uri)
add_subdirectory(message)
add_subdirectory(logging)
Expand Down
32 changes: 16 additions & 16 deletionscontrib/http_examples/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ endif()
add_executable(simple_wget simple_wget.cpp)
add_executable(atom_reader atom/atom.cpp atom/main.cpp)
add_executable(rss_reader rss/rss.cpp rss/main.cpp)
add_executable(twitter_search twitter/search.cpp)
#add_executable(twitter_search twitter/search.cpp)
#add_executable(hello_world_server http/hello_world_server.cpp)
add_executable(hello_world_client http/hello_world_client.cpp)
#if (UNIX)
Expand DownExpand Up@@ -81,19 +81,19 @@ target_link_libraries(rss_reader
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})

target_link_libraries(twitter_search
${BOOST_CLIENT_LIBS}
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-uri
cppnetlib-message
cppnetlib-message-directives
cppnetlib-message-wrappers
cppnetlib-http-message-wrappers
cppnetlib-http-message
cppnetlib-constants
cppnetlib-http-client
cppnetlib-http-client-connections
${CPP-NETLIB_LOGGING_LIB})
#target_link_libraries(twitter_search
# ${BOOST_CLIENT_LIBS}
# ${CMAKE_THREAD_LIBS_INIT}
# cppnetlib-uri
# cppnetlib-message
# cppnetlib-message-directives
# cppnetlib-message-wrappers
# cppnetlib-http-message-wrappers
# cppnetlib-http-message
# cppnetlib-constants
# cppnetlib-http-client
# cppnetlib-http-client-connections
# ${CPP-NETLIB_LOGGING_LIB})

#target_link_libraries(hello_world_server
# ${BOOST_SERVER_LIBS}
Expand All@@ -120,7 +120,7 @@ if (OPENSSL_FOUND)
target_link_libraries(simple_wget ${OPENSSL_LIBRARIES})
target_link_libraries(atom_reader ${OPENSSL_LIBRARIES})
target_link_libraries(rss_reader ${OPENSSL_LIBRARIES})
target_link_libraries(twitter_search ${OPENSSL_LIBRARIES})
#target_link_libraries(twitter_search ${OPENSSL_LIBRARIES})
#target_link_libraries(hello_world_server ${OPENSSL_LIBRARIES})
target_link_libraries(hello_world_client ${OPENSSL_LIBRARIES})
endif (OPENSSL_FOUND)
Expand All@@ -136,7 +136,7 @@ endif (OPENSSL_FOUND)
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(atom_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(rss_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(twitter_search PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
#set_target_properties(twitter_search PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
#set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(hello_world_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
#if (UNIX)
Expand Down
50 changes: 27 additions & 23 deletionscontrib/http_examples/simple_wget.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,39 +27,43 @@ namespace http = network::http;

namespace {
std::string get_filename(const network::uri &url) {
std::string path = network::path(url);
std::size_t index = path.find_last_of('/');
std::string filename = path.substr(index + 1);
auto path = url.path();
if (path) {
auto path_str = std::string(*path);
auto index = path_str.find_last_of('/');
auto filename = path_str.substr(index + 1);
return filename.empty()? "index.html" : filename;
}
return "index.html";
}
} // namespace


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

if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " url" << std::endl;
return 1;
}
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " url" << std::endl;
return 1;
}

try {
http::client client;
http::client::request request(argv[1]);
http::client::response response = client.get(request);
try {
http::client client;
http::client::request request(argv[1]);
http::client::response response = client.get(request);

network::uri uri;
request.get_uri(uri);
std::string filename = get_filename(uri);
std::cout << "Saving to: " << filename << std::endl;
std::ofstream ofs(filename.c_str());
ofs << static_cast<std::string>(body(response)) << std::endl;
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
network::uri uri;
request.get_uri(uri);
std::string filename = get_filename(uri);
std::cout << "Saving to: " << filename << std::endl;
std::ofstream ofs(filename.c_str());
ofs << static_cast<std::string>(body(response)) << std::endl;
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}

return 0;
return 0;
}
//]
7 changes: 4 additions & 3 deletionscontrib/http_examples/twitter/search.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,9 +29,10 @@ int main(int argc, char *argv[]) {
network::uri base_uri("http://search.twitter.com/search.json");

std::cout << "Searching Twitter for query: " << argv[1] << std::endl;
network::uri search;
search << base_uri << network::query("q", network::encoded(argv[1]));
http::client::request request(search);

network::uri_builder builder(base_uri);
builder.query("q", argv[1]))
http::client::request request(builder.uri());
http::client::response response = client.get(request);

Document d;
Expand Down
21 changes: 11 additions & 10 deletionshttp/src/network/protocol/http/algorithms/linearize.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@
#include <network/constants.hpp>
#include <boost/concept/requires.hpp>
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/range/algorithm/copy.hpp>

namespace network {
Expand All@@ -38,8 +39,8 @@ struct linearize_header {
typedef std::ostringstream output_stream;
typedef constants consts;
output_stream header_line;
header_line << name(header)
<< consts::colon() << consts::space()
header_line << name(header)
<< consts::colon() << consts::space()
<< value(header) << consts::crlf();
return header_line.str();
}
Expand All@@ -50,16 +51,16 @@ BOOST_CONCEPT_REQUIRES(
((ClientRequest<Request>)),
(OutputIterator)
) linearize(
Request const & request,
Request const & request,
std::string const & method,
unsigned version_major,
unsigned version_minor,
unsigned version_major,
unsigned version_minor,
OutputIterator oi
)
)
{
typedef constants consts;
typedef std::string string_type;
static string_type
static string_type
http_slash = consts::http_slash()
, accept = consts::accept()
, accept_mime = consts::default_accept_mime()
Expand All@@ -76,7 +77,7 @@ BOOST_CONCEPT_REQUIRES(
*oi = consts::space_char();
{
std::string path_ = path(request);
if (path_.empty() || path_[0] != consts::slash_char())
if (path_.empty() || path_[0] != consts::slash_char())
*oi = consts::slash_char();
boost::copy(path_, oi);
}
Expand DownExpand Up@@ -156,8 +157,8 @@ BOOST_CONCEPT_REQUIRES(
auto body_data = network::body(request);
return std::copy(body_data.begin(), body_data.end(), oi);
}

} // namespace http
} // namespace network

#endif /* NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@
#include <network/uri/uri_io.hpp>
#endif
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>

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

Expand All@@ -39,7 +40,7 @@ struct simple_connection_factory_pimpl {
NETWORK_MESSAGE("simple_connection_factory_pimpl::create_connection(...)");
::network::uri uri_ = http::uri(request);
NETWORK_MESSAGE("destination: " << uri_);
bool https = boost::algorithm::to_lower_copy(::network::scheme(uri_)) == "https";
bool https = boost::algorithm::to_lower_copy(std::string(*uri_.scheme())) == "https";
return std::make_shared<http_async_connection>(
res_delegate_factory_->create_resolver_delegate(service, options.cache_resolved()),
conn_delegate_factory_->create_connection_delegate(service, https, options),
Expand Down
1 change: 1 addition & 0 deletionshttp/src/network/protocol/http/client/facade.ipp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@

#include <network/protocol/http/client/facade.hpp>
#include <network/detail/debug.hpp>
#include <boost/lexical_cast.hpp>

namespace network {
namespace http {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,8 @@ anchor_wrapper::anchor_wrapper(request_base const & request)
anchor_wrapper::operator std::string () const {
::network::uri uri_;
request_.get_uri(uri_);
return fragment(uri_);
auto fragment = uri_.fragment();
return fragment? std::string(*fragment) : std::string();
}

} // namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,8 @@ host_wrapper::host_wrapper(request_base const & request)
host_wrapper::operator std::string () const {
::network::uri uri_;
request_.get_uri(uri_);
return host(uri_);
auto host = uri_.host();
return host? std::string(*host) : std::string("");
}

} // namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,8 @@ path_wrapper::path_wrapper(request_base const & request)
path_wrapper::operator std::string () const {
::network::uri uri_;
request_.get_uri(uri_);
return path(uri_);
auto path = uri_.path();
return path? std::string(*path) : std::string("");
}

} // namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#define NETWORK_PROTOCOL_HTTP_MESSAGE_PORT_HPP_20100618

#include <network/protocol/http/request/request_base.hpp>
#include <boost/cstdint.hpp>
#include <boost/optional.hpp>

namespace network { namespace http {
Expand Down
17 changes: 11 additions & 6 deletionshttp/src/network/protocol/http/message/wrappers/port.ipp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,22 +19,27 @@ port_wrapper::port_wrapper(request_base const & request)
port_wrapper::operator boost::uint16_t () const {
::network::uri uri_;
request_.get_uri(uri_);
boost::optional<boost::uint16_t> optional_port =port_us(uri_);
auto optional_port = uri_.port();
if (!optional_port) {
std::string scheme_ = scheme(uri_);
if (scheme_ == "http") {
auto scheme_ = uri_.scheme();
assert(scheme_);
if (*scheme_ == "http") {
return 80u;
} else if (scheme_ == "https") {
} else if (*scheme_ == "https") {
return 443u;
}
}
returnoptional_port ?*optional_port : 80u;
returnstd::stoul(std::string(*optional_port));
}

port_wrapper::operator boost::optional<boost::uint16_t> () const {
::network::uri uri_;
request_.get_uri(uri_);
return port_us(uri_);
auto optional_port = uri_.port();
if (!optional_port) {
return boost::optional<boost::uint16_t>();
}
return std::stoul(std::string(*optional_port));
}

} // namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,8 @@ query_wrapper::query_wrapper(request_base const & request)
query_wrapper::operator std::string () const {
::network::uri uri_;
request_.get_uri(uri_);
return query(uri_);
auto query = uri_.query();
return query? std::string(*query) : std::string("");
}

} // namespace http
Expand Down
2 changes: 1 addition & 1 deletionhttp/src/network/protocol/http/request/request.ipp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,7 +47,7 @@ struct request_pimpl {
}

void set_uri(std::string const & uri) {
uri_ =uri;
set_uri(::network::uri(uri));
}

void set_uri(::network::uri const & uri) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp