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

Commit6441091

Browse files
committed
Allow the v0.x HTTP server to be built; Refactored HTTP v2 client request and response.
1 parent5d8d744 commit6441091

File tree

20 files changed

+681
-652
lines changed

20 files changed

+681
-652
lines changed

‎CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else()
2828
set(BUILD_SHARED_LIBSOFF)
2929
endif()
3030
set(Boost_USE_MULTITHREADEDON)
31-
set(Boost_COMPONENTSsystemregex filesystemprogram_options)
31+
set(Boost_COMPONENTSsystemregex filesystem )
3232
find_package( Boost 1.53 REQUIRED${Boost_COMPONENTS} )
3333
find_package( OpenSSL )
3434
find_package( Threads )
@@ -168,7 +168,7 @@ if(CPP-NETLIB_BUILD_SINGLE_LIB)
168168
endif()
169169

170170
add_subdirectory(uri)
171-
#add_subdirectory(message)
171+
add_subdirectory(message)
172172
add_subdirectory(logging)
173173
add_subdirectory(error)
174174
add_subdirectory(http)

‎contrib/http_examples/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set(EXAMPLES
2727
foreach(example${EXAMPLES})
2828
add_executable(${example}${example}.cpp)
2929
target_link_libraries(${example}
30-
cppnetlib-uri
30+
network-uri
3131
network-http-v2-client
3232
${Boost_LIBRARIES}
3333
${ICU_LIBRARIES}${ICU_I18N_LIBRARIES}

‎contrib/http_examples/read_headers.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

6-
#include<network/http/v2/client.hpp>
6+
#include<network/http/client.hpp>
77
#include<iostream>
88

9-
namespacehttp= network::http::v2;
10-
9+
namespacehttp= network::http;
1110

1211

1312
int
@@ -20,7 +19,7 @@ main(int argc, char *argv[]) {
2019

2120
try {
2221
http::client client;
23-
http::request request{network::uri{std::string{argv[1]}}};
22+
http::client::request request{network::uri{std::string{argv[1]}}};
2423
request.append_header("Connection","close");
2524
auto future_response = client.head(request);
2625
auto response = future_response.get();

‎contrib/http_examples/simple_wget.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
It demonstrates the use the `uri` and the `http::client`.
1414
*/
1515

16-
#include<network/http/v2/client.hpp>
16+
#include<network/http/client.hpp>
1717
#include<string>
1818
#include<fstream>
1919
#include<iostream>
2020

21-
namespacehttp= network::http::v2;
21+
namespacehttp= network::http;
2222

2323
namespace {
2424
std::stringget_filename(const std::string& path) {
@@ -37,7 +37,7 @@ int main(int argc, char* argv[]) {
3737

3838
try {
3939
http::client client;
40-
http::request request{network::uri{std::string{argv[1]}}};
40+
http::client::request request{network::uri{std::string{argv[1]}}};
4141
request.append_header("Connection","close");
4242
auto future_response = client.get(request);
4343
auto response = future_response.get();

‎http/src/CMakeLists.txt‎

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ include_directories(
1818
if (OPENSSL_FOUND)
1919
include_directories(${OPENSSL_INCLUDE_DIR})
2020
endif()
21-
#
22-
#set(CPP-NETLIB_HTTP_MESSAGE_SRCS
23-
# http/request.cpp
24-
# http/response.cpp)
25-
#
26-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
27-
# add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
28-
# add_dependencies(cppnetlib-http-message
29-
# cppnetlib-message)
30-
# target_link_libraries(cppnetlib-http-message
31-
# ${Boost_LIBRARIES}
32-
# cppnetlib-message)
33-
#endif()
34-
#
35-
#set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
36-
# http/message/wrappers.cpp)
37-
#
38-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
39-
# add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
40-
#endif()
41-
#
21+
22+
set(CPP-NETLIB_HTTP_MESSAGE_SRCS
23+
http/request.cpp
24+
http/response.cpp)
25+
26+
if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
27+
add_library(cppnetlib-http-message ${CPP-NETLIB_HTTP_MESSAGE_SRCS})
28+
add_dependencies(cppnetlib-http-message
29+
cppnetlib-message)
30+
target_link_libraries(cppnetlib-http-message
31+
${Boost_LIBRARIES}
32+
cppnetlib-message)
33+
endif()
34+
35+
set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
36+
http/message/wrappers.cpp)
37+
38+
if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
39+
add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
40+
endif()
41+
4242
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
4343
# http/client_connections.cpp
4444
# http/simple_connection_manager.cpp
@@ -54,24 +54,24 @@ endif()
5454
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
5555
# add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
5656
#endif()
57-
#
58-
#set(CPP-NETLIB_CONSTANTS_SRCS
59-
# constants.cpp)
60-
#
61-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
62-
# add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
63-
#endif()
64-
#
65-
## Server implementation files.
66-
#set(CPP-NETLIB_HTTP_SERVER_SRCS
67-
# http/server/session.cpp
68-
# http/server/simple_sessions.cpp
69-
# http/server/dynamic_dispatcher.cpp)
70-
#
71-
#if (NOT CPP-NETLIB_BUILD_SINGLE_LIB)
72-
# add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
73-
#endif()
74-
#
57+
58+
set(CPP-NETLIB_CONSTANTS_SRCS
59+
constants.cpp)
60+
61+
if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
62+
add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
63+
endif()
64+
65+
# Server implementation files.
66+
set(CPP-NETLIB_HTTP_SERVER_SRCS
67+
http/server/session.cpp
68+
http/server/simple_sessions.cpp
69+
http/server/dynamic_dispatcher.cpp)
70+
71+
if (NOT CPP-NETLIB_BUILD_SINGLE_LIB)
72+
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
73+
endif()
74+
7575
#set(CPP-NETLIB_HTTP_CLIENT_SRCS
7676
# http/client.cpp)
7777
#
@@ -109,29 +109,29 @@ set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS
109109
)
110110
add_library(network-http-v2-client ${CPP-NETLIB_HTTP_V2_CLIENT_SRCS})
111111
add_dependencies(network-http-v2-client
112-
cppnetlib-uri
112+
network-uri
113113
)
114114
target_link_libraries(network-http-v2-client
115115
${Boost_LIBRARIES}
116-
cppnetlib-uri
116+
network-uri
117117
)
118118

119119
# prepend current directory to make paths absolute
120120
prependToElements("${CMAKE_CURRENT_SOURCE_DIR}/"
121-
# CPP-NETLIB_HTTP_MESSAGE_SRCS
122-
# CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
121+
CPP-NETLIB_HTTP_MESSAGE_SRCS
122+
CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
123123
# CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
124-
# CPP-NETLIB_CONSTANTS_SRCS
125-
# CPP-NETLIB_HTTP_SERVER_SRCS
124+
CPP-NETLIB_CONSTANTS_SRCS
125+
CPP-NETLIB_HTTP_SERVER_SRCS
126126
# CPP-NETLIB_HTTP_CLIENT_SRCS
127127
CPP-NETLIB_HTTP_V2_CLIENT_SRCS )
128128

129129

130-
## propagate sources to parent directory for one-lib-build
131-
#set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
132-
#set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
130+
# propagate sources to parent directory for one-lib-build
131+
set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
132+
set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
133133
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
134134
#set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
135-
#set(CPP-NETLIB_HTTP_SERVER_SRCS ${CPP-NETLIB_HTTP_SERVER_SRCS} PARENT_SCOPE)
136-
#set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
135+
set(CPP-NETLIB_HTTP_SERVER_SRCS ${CPP-NETLIB_HTTP_SERVER_SRCS} PARENT_SCOPE)
136+
set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
137137
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS ${CPP-NETLIB_HTTP_V2_CLIENT_SRCS} PARENT SCOPE)

‎http/src/http/v2/client/client.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace network {
236236
}));
237237
}
238238

239-
std::future<response>client::impl::do_request(method met,
239+
std::future<client::response>client::impl::do_request(method met,
240240
request req,
241241
request_options options) {
242242
std::future<response> res = response_promise_.get_future();
@@ -289,29 +289,29 @@ namespace network {
289289
delete pimpl_;
290290
}
291291

292-
std::future<response>client::get(request req, request_options options) {
292+
std::future<client::response>client::get(request req, request_options options) {
293293
return pimpl_->do_request(method::GET, req, options);
294294
}
295295

296-
std::future<response>client::post(request req, request_options options) {
296+
std::future<client::response>client::post(request req, request_options options) {
297297
return pimpl_->do_request(method::POST, req, options);
298298
}
299299

300-
std::future<response>client::put(request req, request_options options) {
300+
std::future<client::response>client::put(request req, request_options options) {
301301
return pimpl_->do_request(method::PUT, req, options);
302302
}
303303

304-
std::future<response>client::delete_(request req, request_options options) {
304+
std::future<client::response>client::delete_(request req, request_options options) {
305305
return pimpl_->do_request(method::DELETE, req, options);
306306
}
307307

308-
std::future<response>client::head(request req, request_options options) {
308+
std::future<client::response>client::head(request req, request_options options) {
309309
return pimpl_->do_request(method::HEAD, req, options);
310310
}
311311

312-
std::future<response>client::options(request req, request_options options) {
312+
std::future<client::response>client::options(request req, request_options options) {
313313
return pimpl_->do_request(method::OPTIONS, req, options);
314314
}
315315
}// namespace v2
316-
}// namespacenetwork
316+
}// namespacehttp
317317
}// namespace network

‎http/src/network/http/client.hpp‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Glyn Matthews 2012.
1+
// Copyright (c) Glyn Matthews 2012, 2013.
22
// Copyright 2012 Dean Michael Berris <dberris@google.com>.
33
// Copyright 2012 Google, Inc.
44
// Distributed under the Boost Software License, Version 1.0.
@@ -8,9 +8,18 @@
88
#ifndef NETWORK_HTTP_CLIENT_INC__
99
#defineNETWORK_HTTP_CLIENT_INC__
1010

11-
#include<network/protocol/http/client.hpp>
12-
#include<network/http/request.hpp>
13-
#include<network/http/response.hpp>
14-
#include<network/http/errors.hpp>
11+
#include<network/http/v2/client.hpp>
12+
#include<network/http/v2/method.hpp>
13+
#include<network/http/v2/status.hpp>
14+
15+
namespacenetwork {
16+
namespacehttp {
17+
using v2::client;
18+
using v2::client_error;
19+
using v2::invalid_url;
20+
using v2::client_exception;
21+
}// namespace http
22+
}// namespace network
23+
1524

1625
#endif// NETWORK_HTTP_CLIENT_INC__

‎http/src/network/http/v2/client/client.hpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ namespace network {
245245

246246
public:
247247

248+
typedef client_message::request_options request_options;
249+
typedef client_message::request request;
250+
typedef client_message::response response;
251+
248252
/**
249253
* \typedef string_type
250254
* \brief The client string_type.

‎http/src/network/http/v2/client/connection/async_connection.hpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ namespace network {
7070

7171
/**
7272
* \brief Asynchronously reads some data from the connection.
73-
* \param read_buffer The buffer in which to read the network data.
73+
* \param command_streambuf
74+
* \param delim A delimiter string which, if found, the socket
75+
* will stop reading.
7476
* \param callback A callback handler.
7577
*/
7678
virtualvoidasync_read_until(boost::asio::streambuf &command_streambuf,
7779
const std::string &delim,
7880
read_callback callback) = 0;
7981

82+
/**
83+
* \brief Asynchronously reads some data from the connection.
84+
* \param command_streambuf
85+
* \param callback A callback handler.
86+
*/
8087
virtualvoidasync_read(boost::asio::streambuf &command_streambuf,
8188
read_callback callback) = 0;
8289

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp