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

Commit12dfac0

Browse files
committed
Work in progress, FIXME: break this down.
1 parent0944773 commit12dfac0

File tree

10 files changed

+364
-14
lines changed

10 files changed

+364
-14
lines changed

‎boost/network/protocol/http/client.hpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ namespace boost { namespace network { namespace http {
8080
}
8181

8282
responseconsthead (requestconst & request_) {
83-
returnsync_request_skeleton(request_,"HEAD",false);
83+
returnrequest_skeleton(request_,"HEAD",false);
8484
};
8585

8686
responseconstget (requestconst & request_) {
87-
returnsync_request_skeleton(request_,"GET",true);
87+
returnrequest_skeleton(request_,"GET",true);
8888
};
8989

9090
responseconstpost (requestconst & request_) {
91-
returnsync_request_skeleton(request_,"POST",true);
91+
returnrequest_skeleton(request_,"POST",true);
9292
};
9393

9494
responseconstpost (request request_, string_typeconst & content_type, string_typeconst & body_) {
@@ -103,7 +103,7 @@ namespace boost { namespace network { namespace http {
103103
};
104104

105105
responseconstput (requestconst & request_) {
106-
returnsync_request_skeleton(request_,"PUT",true);
106+
returnrequest_skeleton(request_,"PUT",true);
107107
};
108108

109109
responseconstput (requestconst & request_, string_typeconst & body_) {
@@ -118,7 +118,7 @@ namespace boost { namespace network { namespace http {
118118
};
119119

120120
responseconstdelete_ (requestconst & request_) {
121-
returnsync_request_skeleton(request_,"DELETE",true);
121+
returnrequest_skeleton(request_,"DELETE",true);
122122
};
123123

124124
private:
@@ -127,7 +127,7 @@ namespace boost { namespace network { namespace http {
127127
boost::asio::io_service service_;
128128
typename connection_base::resolver_type resolver_;
129129

130-
basic_response<Tag>constsync_request_skeleton(basic_request<Tag>const & request_, string_type method,bool get_body) {
130+
basic_response<Tag>constrequest_skeleton(basic_request<Tag>const & request_, string_type method,bool get_body) {
131131
typename connection_base::connection_ptr connection_;
132132
connection_ =connection_base::get_connection(resolver_, request_);
133133
return connection_->send_request(method, request_, get_body);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2010 (C) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/protocol/http/response.hpp>
11+
#include<boost/network/protocol/http/impl/http_async_connection.hpp>
12+
#include<boost/network/protocol/http/impl/https_async_connection.hpp>
13+
14+
namespaceboost {namespacenetwork {namespacehttp {namespaceimpl {
15+
16+
template<classTag,unsigned version_major,unsigned version_minor>
17+
structasync_connection_base {
18+
typedeftypename resolver_policy<Tag>::type resolver_base;
19+
typedeftypename resolver_base::resolver_type resolver_type;
20+
typedeftypename string<Tag>::type string_type;
21+
typedef basic_request<Tag> request;
22+
typedef basic_response<Tag> response;
23+
24+
static async_connection_base<Tag,version_major,version_minor> *new_connection(resolver_type & resolver,bool https) {
25+
if (https) {
26+
returndynamic_cast<async_connection_base<Tag,version_major,version_minor>*>(new https_async_connection<Tag,version_major,version_minor>(resolver));
27+
}
28+
returndynamic_cast<async_connection_base<Tag,version_major,version_minor>*>(new http_async_connection<Tag,version_major,version_minor>(resolver));
29+
}
30+
31+
virtual responsestart(string_typeconst & hostname, string_typeconst & port, requestconst & request) = 0;
32+
33+
};
34+
35+
}// namespace impl
36+
37+
}// namespace http
38+
39+
}// namespace network
40+
41+
}// namespace boost
42+
43+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_IMPL_ASYNC_CONNECTION_BASE_20100529
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2010 (C) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/thread/future.hpp>
11+
#include<boost/cstdint.hpp>
12+
13+
namespaceboost {namespacenetwork {namespacehttp {namespaceimpl {
14+
15+
template<classTag,unsigned version_major,unsigned version_minor>
16+
structasync_connection_base;
17+
18+
template<classTag,unsigned version_major,unsigned version_minor>
19+
structhttp_async_connection
20+
: async_connection_base<Tag,version_major,version_minor> {
21+
typedef async_connection_base<Tag,version_major,version_minor> base;
22+
typedeftypename base::resolver_type resolver_type;
23+
typedeftypename base::response response;
24+
typedeftypename base::string_type string_type;
25+
typedeftypename base::request request;
26+
27+
http_async_connection(resolver_type & resolver)
28+
: resolver_(resolver) {}
29+
30+
virtual responsestart(string_typeconst & hostname, string_typeconst & port, requestconst & request) {
31+
response temp;
32+
source(temp, source_promise.get_future());
33+
destination(temp, destination_promise.get_future());
34+
headers(temp, headers_promise.get_future());
35+
body(temp, body_promise.get_future());
36+
version(temp, version_promise.get_future());
37+
status(temp, status_promise.get_future());
38+
status_message(temp, status_message_promise.get_future());
39+
resolver_.async_resolve();//FIXME -- wire the correct parameters
40+
return temp;
41+
}
42+
43+
private:
44+
voidhandle_resolved(boost::system::error_code & ec) {
45+
if (!ec) {
46+
async_connect();//FIXME -- wire the correct parameters
47+
}
48+
}
49+
50+
voidhandle_connected() {
51+
if (!ec) {
52+
async_send();//FIXME -- wire the correct parameters
53+
}
54+
}
55+
56+
voidhandle_sent_request() {
57+
if (!ec) {
58+
async_read();//FIXME -- wire the correct parameters
59+
}
60+
}
61+
62+
voidhandle_received_status() {
63+
if (!ec) {
64+
async_read();//FIXME -- wire the correct parameters
65+
}
66+
}
67+
68+
voidhandle_received_headers() {
69+
if (!ec) {
70+
async_read();//FIXME -- wire the correct parameters
71+
}
72+
}
73+
74+
voidhandle_recieved_body() {
75+
if (!ec) {
76+
async_read();//FIXME -- wire the correct parameters
77+
}
78+
}
79+
80+
resolver_type & resolver_;
81+
boost::promise<string_type> version_promise;
82+
boost::promise<boost::uint16_t> status_promise;
83+
boost::promise<string_type> status_message_promise;
84+
boost::promise<typename headers_container<Tag>::type> headers_promise;
85+
boost::promise<string_type> source_promise;
86+
boost::promise<string_type> destination_promise;
87+
boost::promise<string_type> body_promise;
88+
};
89+
90+
}// namespace impl
91+
92+
}// namespace http
93+
94+
}// namespace network
95+
96+
}// namespace boost
97+
98+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_ASYNC_CONNECTION_HPP_20100601
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_ASYNC_CONNECTION_HPP_20100601
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2010 (C) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
namespaceboost {namespacenetwork {namespacehttp {namespaceimpl {
11+
12+
template<classTag,unsigned version_major,unsigned version_minor>
13+
structasync_connection_base;
14+
15+
template<classTag,unsigned version_major,unsigned version_minor>
16+
structhttps_async_connection
17+
: async_connection_base<Tag,version_major,version_minor>,
18+
boost::enable_shared_from_this<https_async_connection<Tag,version_major,version_minor> >
19+
{
20+
typedef async_connection_base<Tag,version_major,version_minor> base;
21+
typedeftypename base::resolver_type resolver_type;
22+
typedeftypename base::string_type string_type;
23+
typedeftypename base::response response;
24+
typedeftypename base::request request;
25+
26+
https_async_connection(resolver_type & resolver)
27+
: resolver_(resolver) {}
28+
29+
virtual responsestart(string_typeconst & hostname, string_typeconst & port, requestconst & request) {
30+
response temp;
31+
32+
return temp;
33+
}
34+
35+
private:
36+
voidhandle_resolved();
37+
voidhandle_connected();
38+
voidhandle_sent_request();
39+
voidhandle_received_status();
40+
voidhandle_received_headers();
41+
voidhandle_received_body();
42+
43+
resolver_type & resolver_;
44+
};
45+
46+
}// namespace impl
47+
48+
}// namespace http
49+
50+
}// namespace network
51+
52+
}// namespace boost
53+
54+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTPS_ASYNC_CONNECTION_HPP_20100601
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#ifndef BOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529
2+
#defineBOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_20100529
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2010 (C) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/version.hpp>
11+
#include<boost/shared_ptr.hpp>
12+
#include<boost/lexical_cast.hpp>
13+
#include<boost/cstdint.hpp>
14+
#include<boost/network/protocol/http/traits/resolver_policy.hpp>
15+
#include<boost/network/protocol/http/detail/connection_helper.hpp>
16+
#include<boost/network/protocol/http/impl/async_connection_base.hpp>
17+
#include<boost/tuple/tuple.hpp>
18+
#include<boost/function.hpp>
19+
#include<boost/bind.hpp>
20+
#include<boost/algorithm/string/predicate.hpp>
21+
22+
namespaceboost {namespacenetwork {namespacehttp {
23+
24+
template<classTag,unsigned version_major,unsigned version_minor>
25+
structasync_connection_policy : resolver_policy<Tag>::type {
26+
protected:
27+
28+
typedeftypename string<Tag>::type string_type;
29+
typedeftypename resolver_policy<Tag>::type resolver_base;
30+
typedeftypename resolver_base::resolver_type resolver_type;
31+
typedef function<typenameresolver_base::resolver_iterator_pair(resolver_type &, string_typeconst &, string_typeconst &)> resolver_function_type;
32+
33+
structconnection_impl {
34+
connection_impl(resolver_type & resolver,bool follow_redirect, string_typeconst & hostname, string_typeconst & port, resolver_function_type resolve,bool https)
35+
: pimpl()
36+
, follow_redirect_(follow_redirect)
37+
{
38+
pimpl.reset(impl::async_connection_base<Tag,version_major,version_minor>::new_connection(resolver, resolve, https));
39+
}
40+
41+
basic_response<Tag>send_request(string_typeconst & method, basic_request<Tag>const & request_,bool get_body) {
42+
return pimpl->start(host(request_), lexical_cast<string_type>(port(request_)), follow_redirect_);
43+
}
44+
45+
private:
46+
47+
shared_ptr<http::impl::async_connection_base<Tag, version_major, version_minor> > pimpl;
48+
bool follow_redirect_;
49+
50+
};
51+
52+
typedef boost::shared_ptr<connection_impl> connection_ptr;
53+
connection_ptrget_connection(resolver_type & resolver, basic_request<Tag>const & request_) {
54+
connection_ptrconnection_(
55+
newconnection_impl(
56+
resolver
57+
, follow_redirect_
58+
,host(request)
59+
, lexical_cast<string_type>(port(request))
60+
,boost::bind(
61+
&async_connection_policy<Tag, version_major, version_minor>::resolve,
62+
this,
63+
_1, _2, _3
64+
)
65+
,boost::iequals(protocol(request_),string_type("https"))
66+
)
67+
);
68+
return connection_;
69+
}
70+
71+
voidcleanup() { }
72+
73+
async_connection_policy(bool cache_resolved,bool follow_redirect)
74+
: resolver_base(cache_resolved), follow_redirect_(follow_redirect) {}
75+
76+
bool follow_redirect_;
77+
};
78+
79+
}// namespace http
80+
81+
}// namespace network
82+
83+
}// namespace boost
84+
85+
#endif// BOOST_NETWORK_POLICY_ASYNC_CONNECTION_HPP_
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris.
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/concept_check.hpp>
11+
#include<boost/network/message/message_concept.hpp>
12+
#include<boost/cstdint.hpp>
13+
14+
namespaceboost {namespacenetwork {namespacehttp {
15+
16+
template<classR>
17+
structRequest
18+
: boost::network::Message<R>
19+
{
20+
typedeftypename R::string_type string_type;
21+
typedeftypename R::port_type port_type;
22+
23+
BOOST_CONECEPT_USAGE(Request) {
24+
Rrequest_(string_type());
25+
swap(request_, request_);// swappable via ADL
26+
27+
string_type host_ =host(request);
28+
port_type port =port(request);
29+
string_type path =path(request);
30+
31+
request <<host(string_type())
32+
<<port(port_type())
33+
<<path(string_type())
34+
;
35+
36+
host(request,string_type());
37+
port(request,port_type());
38+
path(request,string_type());
39+
}
40+
41+
private:
42+
R request;
43+
};
44+
45+
}// namespace http
46+
47+
}// namespace network
48+
49+
}// namespace boost
50+
51+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_CONCEPT_HPP_20100603

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp