Skip to content

Commit b1cfe58

Browse files
committed
WIP: Ongoing refactoring...
1 parent 2d78920 commit b1cfe58

File tree

17 files changed

+506
-637
lines changed

17 files changed

+506
-637
lines changed

boost/network/constants.hpp

Lines changed: 28 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -6,149 +6,36 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include <boost/mpl/if.hpp>
10-
119
namespace boost { namespace network {
1210

13-
namespace impl {
14-
template <class Tag>
15-
struct constants_narrow {
16-
17-
static char const * crlf() {
18-
static char crlf_[] = { '\r', '\n', 0 };
19-
return crlf_;
20-
}
21-
22-
static char const * dot() {
23-
static char dot_[] = { '.', 0 };
24-
return dot_;
25-
}
26-
27-
static char dot_char() { return '.'; }
28-
29-
static char const * http_slash() {
30-
static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 };
31-
return http_slash_;
32-
}
33-
34-
static char const * space() {
35-
static char space_[] = {' ', 0};
36-
return space_;
37-
}
38-
39-
static char space_char() { return ' '; }
40-
41-
static char const * slash() {
42-
static char slash_[] = {'/', 0};
43-
return slash_;
44-
}
45-
46-
static char slash_char() { return '/'; }
47-
48-
static char const * host() {
49-
static char host_[] = {'H', 'o', 's', 't', 0};
50-
return host_;
51-
}
52-
53-
static char const * colon() {
54-
static char colon_[] = {':', 0};
55-
return colon_;
56-
}
57-
58-
static char colon_char() { return ':'; }
59-
60-
static char const * accept() {
61-
static char accept_[] = {'A', 'c', 'c', 'e', 'p', 't', 0};
62-
return accept_;
63-
}
64-
65-
static char const * default_accept_mime() {
66-
static char mime_[] = {
67-
'*', '/', '*', 0
68-
};
69-
return mime_;
70-
}
71-
72-
static char const * accept_encoding() {
73-
static char accept_encoding_[] = {
74-
'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0
75-
};
76-
return accept_encoding_;
77-
}
78-
79-
static char const * default_accept_encoding() {
80-
static char default_accept_encoding_[] = {
81-
'i','d','e','n','t','i','t','y',';','q','=','1','.','0',',',' ','*',';','q','=','0',0
82-
};
83-
return default_accept_encoding_;
84-
}
85-
86-
static char const * user_agent() {
87-
static char user_agent_[] = {
88-
'U','s','e','r','-','A','g','e','n','t',0
89-
};
90-
return user_agent_;
91-
}
92-
93-
static char const * cpp_netlib_slash() {
94-
static char cpp_netlib_slash_[] = {
95-
'c','p','p','-','n','e','t','l','i','b','/',0
96-
};
97-
return cpp_netlib_slash_;
98-
}
99-
100-
static char question_mark_char() {
101-
return '?';
102-
}
103-
104-
static char hash_char() {
105-
return '#';
106-
}
107-
108-
static char const * connection() {
109-
static char connection_[] = {
110-
'C','o','n','n','e','c','t','i','o','n',0
111-
};
112-
return connection_;
113-
}
114-
115-
static char const * close() {
116-
static char close_[] = {
117-
'C','l','o','s','e', 0
118-
};
119-
return close_;
120-
}
121-
122-
static char const * https() {
123-
static char https_[] = "https";
124-
return https_;
125-
}
126-
127-
};
128-
129-
template <class Tag>
130-
struct constants_wide {
131-
132-
static wchar_t const * https() {
133-
static wchar_t https_[] = L"https";
134-
return https_;
135-
}
136-
137-
};
138-
}
139-
140-
template <class Tag>
141-
struct constants :
142-
mpl::if_<
143-
is_default_string<Tag>,
144-
impl::constants_narrow<Tag>,
145-
typename mpl::if_<
146-
is_default_wstring<Tag>,
147-
impl::constants_wide<Tag>,
148-
unsupported_tag<Tag>
149-
>::type
150-
>::type
151-
{};
11+
struct constants {
12+
static char const * crlf();
13+
static char const * dot();
14+
static char dot_char();
15+
static char const * http_slash();
16+
static char const * space();
17+
static char space_char();
18+
static char const * slash();
19+
static char slash_char();
20+
static char const * host();
21+
static char const * colon();
22+
static char colon_char();
23+
static char const * accept();
24+
static char const * default_accept_mime();
25+
static char const * accept_encoding();
26+
static char const * default_accept_encoding();
27+
static char const * user_agent();
28+
static char const * cpp_netlib_slash();
29+
static char question_mark_char();
30+
static char hash_char();
31+
static char const * connection();
32+
static char const * close();
33+
static char const * https();
34+
};
35+
36+
#ifdef BOOST_NETWORK_NO_LIB
37+
#include <boost/network/constants.ipp>
38+
#endif
15239

15340
} // namespace network
15441

boost/network/constants.ipp

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#ifndef BOOST_NETWORK_CONSTANTS_HPP_20111008
2+
#define BOOST_NETWORK_CONSTANTS_HPP_20111008
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, 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+
namespace boost { namespace network {
11+
12+
char const * constants::crlf() {
13+
static char crlf_[] = { '\r', '\n', 0 };
14+
return crlf_;
15+
}
16+
17+
char const * constants::dot() {
18+
static char dot_[] = { '.', 0 };
19+
return dot_;
20+
}
21+
22+
char constants::dot_char() { return '.'; }
23+
24+
char const * constants::http_slash() {
25+
static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 };
26+
return http_slash_;
27+
}
28+
29+
char const * constants::space() {
30+
static char space_[] = {' ', 0};
31+
return space_;
32+
}
33+
34+
char constants::space_char() { return ' '; }
35+
36+
char const * constants::slash() {
37+
static char slash_[] = {'/', 0};
38+
return slash_;
39+
}
40+
41+
char constants::slash_char() { return '/'; }
42+
43+
char const * constants::host() {
44+
static char host_[] = {'H', 'o', 's', 't', 0};
45+
return host_;
46+
}
47+
48+
char const * constants::colon() {
49+
static char colon_[] = {':', 0};
50+
return colon_;
51+
}
52+
53+
char constants::colon_char() { return ':'; }
54+
55+
char const * constants::accept() {
56+
static char accept_[] = {'A', 'c', 'c', 'e', 'p', 't', 0};
57+
return accept_;
58+
}
59+
60+
char const * constants::default_accept_mime() {
61+
static char mime_[] = {
62+
'*', '/', '*', 0
63+
};
64+
return mime_;
65+
}
66+
67+
char const * constants::accept_encoding() {
68+
static char accept_encoding_[] = {
69+
'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0
70+
};
71+
return accept_encoding_;
72+
}
73+
74+
char const * constants::default_accept_encoding() {
75+
static char default_accept_encoding_[] = {
76+
'i','d','e','n','t','i','t','y',';','q','=','1','.','0',',',' ','*',';','q','=','0',0
77+
};
78+
return default_accept_encoding_;
79+
}
80+
81+
char const * constants::user_agent() {
82+
static char user_agent_[] = {
83+
'U','s','e','r','-','A','g','e','n','t',0
84+
};
85+
return user_agent_;
86+
}
87+
88+
char const * constants::cpp_netlib_slash() {
89+
static char cpp_netlib_slash_[] = {
90+
'c','p','p','-','n','e','t','l','i','b','/',0
91+
};
92+
return cpp_netlib_slash_;
93+
}
94+
95+
char constants::question_mark_char() {
96+
return '?';
97+
}
98+
99+
char constants::hash_char() {
100+
return '#';
101+
}
102+
103+
char const * constants::connection() {
104+
static char connection_[] = {
105+
'C','o','n','n','e','c','t','i','o','n',0
106+
};
107+
return connection_;
108+
}
109+
110+
char const * constants::close() {
111+
static char close_[] = {
112+
'C','l','o','s','e', 0
113+
};
114+
return close_;
115+
}
116+
117+
char const * constants::https() {
118+
static char https_[] = "https";
119+
return https_;
120+
}
121+
122+
} /* network */
123+
124+
} /* boost */
125+
126+
#endif /* BOOST_NETWORK_CONSTANTS_HPP_20111008 */

boost/network/protocol/http/client.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
#include <boost/network/protocol/http/client/facade.hpp>
1313
#include <boost/network/protocol/http/client/parameters.hpp>
1414
#include <boost/network/protocol/http/client/macros.hpp>
15+
#include <boost/network/protocol/http/request.hpp>
16+
#include <boost/network/protocol/http/response.hpp>
1517

1618
namespace boost { namespace network { namespace http {
1719

18-
template <class String>
19-
struct basic_client : basic_client_facade {
20+
struct client : basic_client_facade {
2021
private:
2122
typedef basic_client_facade
2223
base_facade_type;
2324
public:
24-
typedef basic_request<String> request;
25-
typedef basic_response<String> response;
26-
typedef String string_type;
25+
typedef ::boost::network::http::request request;
26+
typedef ::boost::network::http::response response;
2727

2828
// Constructor
2929
// =================================================================

0 commit comments

Comments
 (0)