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

Commit18271fe

Browse files
committed
Support for BOOST_NETWORK_NO_LIB (server)
This commit adds support for BOOST_NETWORK_NO_LIB for server includes.
1 parent1675db0 commit18271fe

File tree

5 files changed

+125
-39
lines changed

5 files changed

+125
-39
lines changed

‎boost/network/protocol/http/server/async_connection.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include<list>
2929
#include<vector>
3030
#include<iterator>
31+
#ifdef BOOST_NETWORK_NO_LIB
32+
#include<boost/network/protocol/http/server/impl/parsers.ipp>
33+
#endif
3134

3235
#ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE
3336
/** Here we define a page's worth of header connection buffer data.
@@ -46,8 +49,10 @@
4649

4750
namespaceboost {namespacenetwork {namespacehttp {
4851

52+
#ifndef BOOST_NETWORK_NO_LIB
4953
externvoidparse_version(std::stringconst & partial_parsed, fusion::tuple<uint8_t,uint8_t> & version_pair);
5054
externvoidparse_headers(std::stringconst & input, std::vector<request_header_narrow> & container);
55+
#endif
5156

5257
template<classTag,classHandler>
5358
structasync_connection : boost::enable_shared_from_this<async_connection<Tag,Handler> > {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef SERVER_REQUEST_PARSERS_IMPL_UW3PM6V6
2+
#defineSERVER_REQUEST_PARSERS_IMPL_UW3PM6V6
3+
4+
#include<boost/spirit/include/qi.hpp>
5+
6+
// Copyright 2010 Dean Michael Berris.
7+
// Distributed under the Boost Software License, Version 1.0.
8+
// (See accompanying file LICENSE_1_0.txt or copy at
9+
// http://www.boost.org/LICENSE_1_0.txt)
10+
11+
#include<boost/network/protocol/http/message/header.hpp>
12+
#include<boost/fusion/tuple.hpp>
13+
14+
#ifdef BOOST_NETWORK_NO_LIB
15+
#ifndef BOOST_NETWORK_INLINE
16+
#defineBOOST_NETWORK_INLINEinline
17+
#endif
18+
#else
19+
#defineBOOST_NETWORK_INLINE
20+
#endif
21+
#include<vector>
22+
23+
namespaceboost {namespacenetwork {namespacehttp {
24+
25+
BOOST_NETWORK_INLINEvoidparse_version(std::stringconst & partial_parsed, fusion::tuple<uint8_t,uint8_t> & version_pair) {
26+
usingnamespaceboost::spirit::qi;
27+
parse(
28+
partial_parsed.begin(), partial_parsed.end(),
29+
(
30+
lit("HTTP/")
31+
>> ushort_
32+
>>'.'
33+
>> ushort_
34+
)
35+
, version_pair);
36+
}
37+
38+
BOOST_NETWORK_INLINEvoidparse_headers(std::stringconst & input, std::vector<request_header_narrow> & container) {
39+
usingnamespaceboost::spirit::qi;
40+
parse(
41+
input.begin(), input.end(),
42+
*(
43+
+(alnum|(punct-':'))
44+
>>lit(":")
45+
>> +((alnum|space|punct) -'\r' -'\n')
46+
>>lit("\r\n")
47+
)
48+
>>lit("\r\n")
49+
, container
50+
);
51+
}
52+
53+
}/* http*/
54+
55+
}/* network*/
56+
57+
}/* boost*/
58+
59+
#endif/* SERVER_REQUEST_PARSERS_IMPL_UW3PM6V6*/
Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
1-
#include<boost/spirit/include/qi.hpp>
2-
31
// Copyright 2010 Dean Michael Berris.
42
// Distributed under the Boost Software License, Version 1.0.
53
// (See accompanying file LICENSE_1_0.txt or copy at
64
// http://www.boost.org/LICENSE_1_0.txt)
75

8-
#include<boost/network/protocol/http/message/header.hpp>
9-
#include<boost/fusion/tuple.hpp>
10-
#include<vector>
11-
12-
namespaceboost {namespacenetwork {namespacehttp {
13-
14-
voidparse_version(std::stringconst & partial_parsed, fusion::tuple<uint8_t,uint8_t> & version_pair) {
15-
usingnamespaceboost::spirit::qi;
16-
parse(
17-
partial_parsed.begin(), partial_parsed.end(),
18-
(
19-
lit("HTTP/")
20-
>> ushort_
21-
>>'.'
22-
>> ushort_
23-
)
24-
, version_pair);
25-
}
6+
#ifdef BOOST_NETWORK_NO_LIB
7+
#undef BOOST_NETWORK_NO_LIB
8+
#endif
269

27-
voidparse_headers(std::stringconst & input, std::vector<request_header_narrow> & container) {
28-
usingnamespaceboost::spirit::qi;
29-
parse(
30-
input.begin(), input.end(),
31-
*(
32-
+(alnum|(punct-':'))
33-
>>lit(":")
34-
>> +((alnum|space|punct) -'\r' -'\n')
35-
>>lit("\r\n")
36-
)
37-
>>lit("\r\n")
38-
, container
39-
);
40-
}
10+
#include<boost/network/protocol/http/server/impl/parsers.ipp>
4111

42-
}/* http*/
43-
44-
}/* network*/
45-
46-
}/* boost*/

‎libs/network/test/http/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ if (Boost_FOUND)
9292

9393
set (INLINED_TESTS
9494
client_include_inlined
95+
server_include_inlined
9596
)
9697
foreach (test${INLINED_TESTS} )
9798
if (${CMAKE_CXX_COMPILER_ID}MATCHESGNU)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2009 (c) Tarro, Inc.
2+
// Copyright 2009-2010 (c) Dean Michael Berris <mikhailberis@gmail.com>
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
#include<cstdlib>
9+
#include<boost/config/warning_disable.hpp>
10+
#defineBOOST_NETWORK_NO_LIB
11+
#include<boost/network/protocol/http/server.hpp>
12+
#include<boost/thread/thread.hpp>
13+
#include<boost/assign/list_of.hpp>
14+
#include<boost/lexical_cast.hpp>
15+
#include<string>
16+
#include<iostream>
17+
18+
namespacehttp= boost::network::http;
19+
using boost::assign::list_of;
20+
using boost::lexical_cast;
21+
using std::string;
22+
using std::cerr;
23+
using std::endl;
24+
25+
structhello_world;
26+
typedef http::server<hello_world> server;
27+
28+
structhello_world {
29+
30+
voidoperator()(server::requestconst & request, server::response & response) {
31+
static server::response::header_type header = {"Connection","close"};
32+
response =server::response::stock_reply(server::response::ok,"Hello, World!");
33+
response.headers.push_back(header);
34+
assert(response.status == server::response::ok);
35+
assert(response.headers.size() ==3);
36+
assert(response.content =="Hello, World!");
37+
}
38+
39+
voidlog(stringconst & data) {
40+
cerr << data << endl;
41+
abort();
42+
}
43+
44+
};
45+
46+
intmain(int argc,char * argv[]) {
47+
hello_world handler;
48+
std::string port ="8000";
49+
if (argc >1) port = argv[1];
50+
serverserver_("127.0.0.1", port, handler, http::_reuse_address=true);
51+
boost::threadrunner(boost::bind(&server::run, &server_));
52+
server_.stop();
53+
runner.join();
54+
return EXIT_SUCCESS;
55+
}
56+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp