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

Commitc1d5ba4

Browse files
committed
Merge pull request#5 from glynos/0.9-devel
0.9 devel
2 parentsa8d0d57 +afb4927 commitc1d5ba4

32 files changed

+1414
-103
lines changed

‎CMakeLists.txt‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ if (Boost_FOUND)
1717
set(Boost_USE_STATIC_LIBSON)
1818
set(Boost_USE_MULTI_THREADEDON)
1919
include_directories(${Boost_INCLUDE_DIRS})
20-
endif()
20+
endif(Boost_FOUND)
21+
if (MSVC)
22+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
23+
endif(MSVC)
24+
if (WIN32)
25+
add_definitions(-D_WIN32_WINNT=0x0501)
26+
endif(WIN32)
2127
enable_testing()
2228

2329
if (OPENSSL_FOUND)
@@ -26,6 +32,8 @@ endif()
2632

2733
add_subdirectory(libs/network/src)
2834
add_subdirectory(libs/network/test)
29-
add_subdirectory(libs/mime/test)
35+
if (NOTMSVC)
36+
add_subdirectory(libs/mime/test)
37+
endif(NOTMSVC)
3038
add_subdirectory(libs/network/example)
3139

‎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))throwboost::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
throwstd::runtime_error("Size mismatch between tranfer encoding chunk data size and declared chunk size.");
166-
}
166+
}
167167
}while (!stopping);
168168
}elsethrowstd::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/message/async_message.hpp‎

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

1212
#include<boost/thread/future.hpp>
1313
#include<boost/cstdint.hpp>
14+
#include<boost/optional.hpp>
1415

1516
//FIXME move this out to a trait
1617
#include<set>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace boost { namespace network { namespace http {
3030
typedeftypename resolver_base::resolver_type resolver_type;
3131
typedef function<typenameresolver_base::resolver_iterator_pair(resolver_type &, string_typeconst &, string_typeconst &)> resolver_function_type;
3232
typedef function<void(iterator_range<charconst *>const &, system::error_codeconst &)> body_callback_function_type;
33-
33+
3434
voidcleanup() {
3535
host_connection_map().swap(host_connections);
3636
}
@@ -85,9 +85,9 @@ namespace boost { namespace network { namespace http {
8585
pimpl->read_headers(response_, response_buffer);
8686

8787
if (
88-
get_body && response_.status() !=304
88+
get_body && response_.status() !=304
8989
&& (response_.status() !=204)
90-
&&not(response_.status() >=100 && response_.status() <=199)
90+
&&!(response_.status() >=100 && response_.status() <=199)
9191
) {
9292
pimpl->read_body(response_, response_buffer);
9393
}
@@ -125,7 +125,7 @@ namespace boost { namespace network { namespace http {
125125
};
126126

127127
typedef shared_ptr<connection_impl> connection_ptr;
128-
128+
129129
typedef unordered_map<string_type, connection_ptr> host_connection_map;
130130
host_connection_map host_connections;
131131
bool follow_redirect_;
@@ -164,7 +164,7 @@ namespace boost { namespace network { namespace http {
164164

165165
pooled_connection_policy(bool cache_resolved,bool follow_redirect)
166166
: resolver_base(cache_resolved), host_connections(), follow_redirect_(follow_redirect) {}
167-
167+
168168
};
169169

170170
}// namespace http

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace boost { namespace network { namespace http {
3030
typedef function<void(iterator_range<charconst *>const &, system::error_codeconst &)> body_callback_function_type;
3131

3232
structconnection_impl {
33-
connection_impl(resolver_type & resolver,bool follow_redirect, string_typeconst & hostname, string_typeconst & 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>())
33+
connection_impl(resolver_type & resolver,bool follow_redirect, string_typeconst & hostname, string_typeconst & 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>())
3434
: pimpl()
35-
, follow_redirect_(follow_redirect)
35+
, follow_redirect_(follow_redirect)
3636
{
3737
pimpl.reset(impl::sync_connection_base<Tag,version_major,version_minor>::new_connection(resolver, resolve, https, certificate_filename, verify_path));
3838
}
@@ -55,7 +55,7 @@ namespace boost { namespace network { namespace http {
5555
boost::uint16_t status = response_.status();
5656
if (status >=300 && status <=307) {
5757
typename headers_range<http::basic_response<Tag> >::type location_range =headers(response_)["Location"];
58-
typename range_iterator<typename headers_range<http::basic_request<Tag> >::type>::type location_header =boost::begin(location_range);
58+
typename range_iterator<typename headers_range<http::basic_response<Tag> >::type>::type location_header =boost::begin(location_range);
5959
if (location_header !=boost::end(location_range)) {
6060
request_.uri(location_header->second);
6161
}elsethrowstd::runtime_error("Location header not defined in redirect response.");
@@ -98,7 +98,7 @@ namespace boost { namespace network { namespace http {
9898

9999
voidcleanup() { }
100100

101-
simple_connection_policy(bool cache_resolved,bool follow_redirect)
101+
simple_connection_policy(bool cache_resolved,bool follow_redirect)
102102
: resolver_base(cache_resolved), follow_redirect_(follow_redirect) {}
103103

104104
// member variables

‎boost/network/uri/uri_accessors.hpp‎renamed to ‎boost/network/uri/accessors.hpp‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
// Copyright (c) Glyn Matthews 2011.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
17
#ifndef __BOOST_NETWORK_URI_URI_ACCESSORS_INC__
28
#define__BOOST_NETWORK_URI_URI_ACCESSORS_INC__
39

410

511
#include<boost/network/uri/uri.hpp>
12+
#include<boost/network/uri/encode.hpp>
13+
#include<boost/network/uri/decode.hpp>
614
#include<boost/spirit/include/qi.hpp>
715

816

@@ -74,6 +82,36 @@ typename basic_uri<Tag>::string_type password(const basic_uri<Tag> &uri) {
7482
}
7583
returntypename string<Tag>::type(it,boost::end(user_info_range));
7684
}
85+
86+
template<
87+
classTag
88+
>
89+
typename basic_uri<Tag>::string_typedecoded_path(const basic_uri<Tag> &uri) {
90+
typename basic_uri<Tag>::const_range_type path_range = uri.path_range();
91+
typename basic_uri<Tag>::string_type decoded_path;
92+
decode(path_range,std::back_inserter(decoded_path));
93+
return decoded_path;
94+
}
95+
96+
template<
97+
classTag
98+
>
99+
typename basic_uri<Tag>::string_typedecoded_query(const basic_uri<Tag> &uri) {
100+
typename basic_uri<Tag>::const_range_type query_range = uri.query_range();
101+
typename basic_uri<Tag>::string_type decoded_query;
102+
decode(query_range,std::back_inserter(decoded_query));
103+
return decoded_query;
104+
}
105+
106+
template<
107+
classTag
108+
>
109+
typename basic_uri<Tag>::string_typedecoded_fragment(const basic_uri<Tag> &uri) {
110+
typename basic_uri<Tag>::const_range_type fragment_range = uri.fragment_range();
111+
typename basic_uri<Tag>::string_type decoded_fragment;
112+
decode(fragment_range,std::back_inserter(decoded_fragment));
113+
return decoded_fragment;
114+
}
77115
}// namespace uri
78116
}// namespace network
79117
}// namespace boost

‎boost/network/uri/decode.hpp‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright (c) Glyn Matthews 2011.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
7+
#ifndef __BOOST_NETWORK_URI_DECODE_INC__
8+
#define__BOOST_NETWORK_URI_DECODE_INC__
9+
10+
11+
#include<boost/iterator/iterator_traits.hpp>
12+
#include<boost/range/begin.hpp>
13+
#include<boost/range/end.hpp>
14+
#include<cassert>
15+
16+
17+
namespaceboost {
18+
namespacenetwork {
19+
namespaceuri {
20+
namespacedetail {
21+
template<
22+
typename CharT
23+
>
24+
CharTletter_to_hex(CharT in)
25+
{
26+
switch (in)
27+
{
28+
case'0':
29+
case'1':
30+
case'2':
31+
case'3':
32+
case'4':
33+
case'5':
34+
case'6':
35+
case'7':
36+
case'8':
37+
case'9':
38+
return in -'0';
39+
case'a':
40+
case'b':
41+
case'c':
42+
case'd':
43+
case'e':
44+
case'f':
45+
return in +10 -'a';
46+
case'A':
47+
case'B':
48+
case'C':
49+
case'D':
50+
case'E':
51+
case'F':
52+
return in +10 -'A';
53+
}
54+
returnCharT();
55+
}
56+
}// namespace detail
57+
58+
template<
59+
classInputIterator,
60+
classOutputIterator
61+
>
62+
OutputIteratordecode(const InputIterator &in_begin,
63+
const InputIterator &in_end,
64+
const OutputIterator &out_begin) {
65+
typedeftypename boost::iterator_value<InputIterator>::type value_type;
66+
67+
InputIterator it = in_begin;
68+
OutputIterator out = out_begin;
69+
while (it != in_end) {
70+
if (*it =='%')
71+
{
72+
++it;
73+
value_type v0 =detail::letter_to_hex(*it);
74+
++it;
75+
value_type v1 =detail::letter_to_hex(*it);
76+
++it;
77+
*out++ =0x10 * v0 + v1;
78+
}
79+
else
80+
{
81+
*out++ = *it++;
82+
}
83+
}
84+
return out;
85+
}
86+
87+
template<
88+
classSinglePassRange,
89+
classOutputIterator
90+
>
91+
inline
92+
OutputIteratordecode(const SinglePassRange &range,
93+
const OutputIterator &out) {
94+
returndecode(boost::begin(range),boost::end(range), out);
95+
}
96+
}// namespace uri
97+
}// namespace network
98+
}// namespace boost
99+
100+
101+
#endif// __BOOST_NETWORK_URI_DECODE_INC__

‎boost/network/uri/detail/parse_uri.hpp‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,35 @@ struct uri_grammar : qi::grammar<Iterator, detail::uri_parts<String>()> {
106106
>> iter_pos
107107
;
108108

109+
ip_literal %=
110+
qi::lit('[') >> (ipv6address | ipvfuture) >>']'
111+
;
112+
113+
ipvfuture %=
114+
qi::lit('v') >> +qi::xdigit >>'.' >> +( unreserved | sub_delims |':')
115+
;
116+
117+
ipv6address %= qi::raw[
118+
qi::repeat(6)[h16 >>':'] >> ls32
119+
|"::" >>qi::repeat(5)[h16 >>':'] >> ls32
120+
| qi::raw[ h16] >>"::" >>qi::repeat(4)[h16 >>':'] >> ls32
121+
| qi::raw[ +(*(h16 >>':')) >> h16] >>"::" >>qi::repeat(3)[h16 >>':'] >> ls32
122+
| qi::raw[qi::repeat(2)[*(h16 >>':')] >> h16] >>"::" >>qi::repeat(2)[h16 >>':'] >> ls32
123+
| qi::raw[qi::repeat(3)[*(h16 >>':')] >> h16] >>"::" >> h16 >>':' >> ls32
124+
| qi::raw[qi::repeat(4)[*(h16 >>':')] >> h16] >>"::" >> ls32
125+
| qi::raw[qi::repeat(5)[*(h16 >>':')] >> h16] >>"::" >> h16
126+
| qi::raw[qi::repeat(6)[*(h16 >>':')] >> h16] >>"::"
127+
128+
];
129+
130+
// ls32 = ( h16 ":" h16 ) / IPv4address
131+
ls32 %= (h16 >>':' >> h16) | ipv4address
132+
;
133+
134+
// h16 = 1*4HEXDIG
135+
h16 %=qi::repeat(1,4)[qi::xdigit]
136+
;
137+
109138
// dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35
110139
dec_octet %=
111140
!(qi::lit('0') >> qi::digit)
@@ -126,7 +155,7 @@ struct uri_grammar : qi::grammar<Iterator, detail::uri_parts<String>()> {
126155
// TODO, host = IP-literal / IPv4address / reg-name
127156
host %=
128157
iter_pos
129-
>> qi::omit[ipv4address | reg_name]
158+
>> qi::omit[ip_literal |ipv4address | reg_name]
130159
>> iter_pos
131160
;
132161

@@ -193,7 +222,10 @@ struct uri_grammar : qi::grammar<Iterator, detail::uri_parts<String>()> {
193222
path_abempty, path_absolute, path_rootless, path_empty;
194223

195224
qi::rule<Iterator, String()>
196-
dec_octet, ipv4address, reg_name;
225+
dec_octet, ipv4address, reg_name, ipv6address, ipvfuture, ip_literal;
226+
227+
qi::rule<Iterator, String()>
228+
h16, ls32;
197229

198230
qi::rule<Iterator, iterator_range<String>()>
199231
host, port;

‎boost/network/uri/directives.hpp‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_INC__
2+
#define__BOOST_NETWORK_URI_DIRECTIVES_INC__
3+
4+
5+
#include<boost/network/uri/uri.hpp>
6+
#include<boost/network/uri/directives/scheme.hpp>
7+
#include<boost/network/uri/directives/user_info.hpp>
8+
#include<boost/network/uri/directives/host.hpp>
9+
#include<boost/network/uri/directives/port.hpp>
10+
#include<boost/network/uri/directives/authority.hpp>
11+
#include<boost/network/uri/directives/path.hpp>
12+
#include<boost/network/uri/directives/query.hpp>
13+
#include<boost/network/uri/directives/fragment.hpp>
14+
15+
16+
namespaceboost {
17+
namespacenetwork {
18+
namespaceuri {
19+
template<
20+
classTag
21+
,classDirective
22+
>
23+
inline
24+
basic_uri<Tag> &operator << (basic_uri<Tag> &uri,const Directive &directive) {
25+
directive(uri);
26+
return uri;
27+
}
28+
}// namespace uri
29+
}// namespace network
30+
}// namespace boost
31+
32+
33+
#endif// __BOOST_NETWORK_URI_DIRECTIVES_INC__

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp