Skip to content

Commit a17616a

Browse files
committed
Merge branch '0.5-devel' of [email protected]:mikhailberis/cpp-netlib into 0.5-devel
2 parents 3562f27 + 1379ae3 commit a17616a

31 files changed

+578
-232
lines changed

boost/network/protocol/http/connection.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ namespace boost { namespace network { namespace http {
4545
, socket_(service_)
4646
, wrapper_(service_)
4747
{
48-
try {
49-
socket_.set_option(tcp::no_delay(true)); // Don't delay writing
50-
} catch (system::system_error & e) {
51-
handler_.log(e.what());
52-
}
5348
}
5449

5550
tcp::socket & socket() {
@@ -62,6 +57,9 @@ namespace boost { namespace network { namespace http {
6257
// and then pass that request object to the
6358
// handler_ instance.
6459
//
60+
boost::system::error_code option_error;
61+
socket_.set_option(tcp::no_delay(true), option_error);
62+
if (option_error) handler_.log(system::system_error(option_error).what());
6563
socket_.async_read_some(
6664
boost::asio::buffer(buffer_),
6765
wrapper_.wrap(

index.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml">
5+
<head>
6+
<meta http-equiv="refresh" content="0; URL=libs/network/doc/html/index.html" />
7+
8+
<title></title>
9+
<link rel="stylesheet" href="libs/network/doc/boostbook.css" type="text/css" />
10+
</head>
11+
12+
<body>
13+
Automatic redirection failed, please go to <a href=
14+
"libs/network/doc/html/index.html">index.html</a>.
15+
16+
<div class="copyright-footer">
17+
<p>Copyright 2010 Glyn Matthews</p>
18+
19+
<p>Distributed under the Boost Software License, Version 1.0. (See
20+
accompanying file <a href="LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
21+
at <a href=
22+
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
23+
</div>
24+
</body>
25+
</html>

libs/network/doc/appendices.qbk

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[/
2+
(C) Copyright 2010 Glyn Matthews.
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+
[section:appendices Appendices]
9+
10+
[include message_concept.qbk]
11+
[include uri_concept.qbk]
12+
[include http_uri_concept.qbk]
13+
14+
[endsect] [/ appendices]

libs/network/doc/architecture.qbk

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@
77

88

99
[section:architecture Architecture]
10-
__cnl__ is built upon __boost_asio__, a high-quality, portable asynchronous I/O library that provides a solid interface for C++ network programming.
10+
__cnl__ is built upon __boost_asio__, a high-quality, portable
11+
asynchronous I/O library that provides a solid interface for C++
12+
network programming.
1113

12-
The architecture is driven by the requirement to separate requests from the transport mechanism. Additionally, it's possible to utilise templates and static mechanisms to make decisions at compile-time, resulting in more efficient and stable client code.
14+
The architecture is driven by the requirement to separate requests and
15+
responses from the transport mechanism. Additionally, it utilises
16+
generic programming techniques to make decisions at compile-time,
17+
resulting in more efficient and stable client code.
1318

14-
There are two main features of the architecture which use modern C++ techniques to allow extensibility without comprimising efficiency: tags and directives. These underly the design of the message.
19+
There are two main features of the architecture which use modern C++
20+
techniques to allow extensibility without comprimising efficiency:
21+
tags and directives. It is these techniques that underpin the design
22+
of the message.
1523

1624
[include message.qbk]
1725
[include uri.qbk]
1826

19-
2027
[endsect]

libs/network/doc/contributors.qbk

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[/
2+
(C) Copyright 2010 Glyn Matthews.
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+
[section:contributors Contributors]
9+
[endsect] [/ contributors]

libs/network/doc/examples.qbk

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[/
2-
(C) Copyright 2008, 2009 Glyn Matthews.
2+
(C) Copyright 2008, 2009, 2010 Glyn Matthews.
33
Distributed under the Boost Software License, Version 1.0.
44
(See accompanying file LICENSE_1_0.txt or copy at
55
http://www.boost.org/LICENSE_1_0.txt).
66
]
77

88

99
[section:examples Examples]
10+
[include examples/hello_world.qbk]
1011
[include examples/http_client.qbk]
1112
[include examples/simple_wget.qbk]
1213
[endsect]
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[/
2+
(C) Copyright 2010 Glyn Matthews.
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+
9+
[section:hello_world Hello World]
10+
11+
[import ../../example/http/hello_world_server.cpp]
12+
[hello_world_server_main]
13+
14+
[import ../../example/http/hello_world_client.cpp]
15+
[hello_world_client_main]
16+
17+
[endsect] [/hello_world]
18+

libs/network/doc/examples/http_client.qbk

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
[section:http_client HTTP Client]
1010
[import ../../example/http_client.cpp]
1111
[http_client_main]
12-
[endsect]
12+
[endsect] [/http_client]
1313

libs/network/doc/examples/simple_wget.qbk

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
[section:simple_wget Simple 'wget' Clone]
1111
[import ../../example/simple_wget.cpp]
1212
[simple_wget_main]
13-
[endsect]
13+
[endsect] [/simple_wget]
1414

libs/network/doc/http.qbk

+35-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[/
2-
(C) Copyright 2008, 2009 Glyn Matthews.
2+
(C) Copyright 2008, 2009, 2010 Glyn Matthews.
33
Distributed under the Boost Software License, Version 1.0.
44
(See accompanying file LICENSE_1_0.txt or copy at
55
http://www.boost.org/LICENSE_1_0.txt).
66
]
77

88

99
[section:http HTTP]
10-
The __cnl__ provides direct support for HTTP. As a motivating example, here is the code again from the __quick_start__.
10+
The __cnl__ provides direct support for HTTP. As a motivating
11+
example, here is the code again from the __quick_start__.
1112

1213
#include <boost/network/protocol/http.hpp>
1314
#include <iostream>
@@ -33,7 +34,8 @@ The __cnl__ provides direct support for HTTP. As a motivating example, here is
3334
return 0;
3435
}
3536

36-
Before walking through exactly what is happening in this example, the principle components are described below:
37+
Before walking through exactly what is happening in this example, the
38+
principle components are described below:
3739

3840
[heading HTTP Request]
3941

@@ -42,7 +44,8 @@ Before walking through exactly what is happening in this example, the principle
4244
typedef basic_request<tags::default_> request;
4345
}}}
4446

45-
The [^request] encapsulates information about the request and the resource.
47+
The [^request] encapsulates information about the request and the
48+
resource. It models the Message concept.
4649

4750
[heading HTTP Client]
4851

@@ -51,7 +54,9 @@ The [^request] encapsulates information about the request and the resource.
5154
typedef basic_client<tags::default_> client;
5255
}}}
5356

54-
The [^client] encapsulates the connection-mapping logic between the domain and the underlying socket. Access to a resource is managed through the [^client] object.
57+
The [^client] encapsulates the connection-mapping logic between the
58+
domain and the underlying socket. Access to a resource is managed
59+
through the [^client] object.
5560

5661
[heading HTTP Response]
5762

@@ -60,7 +65,8 @@ The [^client] encapsulates the connection-mapping logic between the domain and t
6065
typedef basic_response<tags::default_> response;
6166
}}}
6267

63-
The [^response] encapsulates the data received from the server.
68+
The [^response] encapsulates the data received from the server. It
69+
also models the Message concept.
6470

6571
[heading Walkthrough]
6672

@@ -70,17 +76,24 @@ This line frames the request for the resource __boost_org__.
7076

7177
http::client client;
7278

73-
Then a client object is created that handles all HTTP requests and responses.
79+
Then a client object is created that handles all HTTP requests and
80+
responses.
7481

7582
http::response response = client.get(request);
7683

77-
The client simply performs the requests. The interface is trivially easy. All HTTP methods are supported (HEAD, GET, POST, PUT, DELETE).
84+
The client simply performs the requests. The interface is trivially
85+
easy. All HTTP methods are supported (HEAD, GET, POST, PUT, DELETE).
7886

7987
There are several advantages to this design:
8088

81-
# A [^client] object manages the connection, unencumbering the developer with this task;
82-
# A [^request] can be used with any instance of the [^client] without binding the [^client] to any destination;
83-
# By decoupling the method from the [^request] object it allows developers to create requests that may be re-used (e.g. perform a HEAD first; if the the headers don't fulfil a certain criteria, perform a GET using the same resource).
89+
# A [^client] object manages the connection, unencumbering the
90+
developer with this task;
91+
# A [^request] can be used with any instance of the [^client] without
92+
binding the [^client] to any destination;
93+
# By decoupling the method from the [^request] object it allows
94+
developers to create requests that may be re-used (e.g. perform a
95+
HEAD first; if the the headers don't fulfil a certain criteria,
96+
perform a GET using the same resource).
8497

8598
// print response headers
8699
headers_range<http::response>::type hdrs = headers(response);
@@ -93,8 +106,9 @@ There are several advantages to this design:
93106
// print response body
94107
std::cout << body(response) << std::endl;
95108

96-
Once the request has been made, and the [^client] returns a [^response] object, the rest is simple. This example outputs all the response headers and body, in this case just the Boost homepage.
97-
109+
Once the request has been made, and the [^client] returns a
110+
[^response] object, the rest is simple. This example outputs all the
111+
response headers and body, in this case just the Boost homepage.
98112

99113
[heading Using [^http::client]]
100114

@@ -112,9 +126,14 @@ HTTP features can be enabled by using constructor arguments:
112126
* [^http::client(http::client::follow_redirect)]
113127

114128
[h5 [^http::client::cache_resolved]]
115-
This argument enables the caching of resolved endpoints and prevents the client from resolving IP addresses of previously resolved hostnames.
129+
This argument enables the caching of resolved endpoints and prevents
130+
the client from resolving IP addresses of previously resolved
131+
hostnames.
116132

117133
[h5 [^http::client::follow_redirect(s)]]
118-
[^http::client::follow_redirects] / [^http::client::follow_redirect] follow HTTP redirect(s) (300..307) by looking at the "Location" header provided by the response(s); headers present in the original request are preserved in the subsequent request(s).
134+
[^http::client::follow_redirects] / [^http::client::follow_redirect]
135+
follow HTTP redirect(s) (300..307) by looking at the "Location" header
136+
provided by the response(s); headers present in the original request
137+
are preserved in the subsequent request(s).
119138

120-
[endsect]
139+
[endsect] [/http]

libs/network/doc/http_uri_concept.qbk

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[/
2+
(C) Copyright 2010 Glyn Matthews.
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+
9+
[section:http_uri HTTP URI Concept]
10+
11+
A type models the HTTP URI Concept if the type adheres to the following
12+
usage semantics, and if the type also models the URI Concept.
13+
14+
[variablelist Notation
15+
[[`H`] [An HTTP URI Type.]]
16+
[[`h`,`h_`] [An HTTP URI Type instance.]]
17+
[[`S`] [A String Type.]]
18+
[[`s`] [A String Type instance.]]
19+
]
20+
21+
[heading Valid Expressions]
22+
23+
For any HTTP URI, the following expressions must be valid:
24+
25+
[table
26+
[[Expression] [Return Type] [Description]]
27+
[[`user_info(h)`] [S] [Retrieve the user-info part of the HTTP URI.]]
28+
[[`host(h)`] [S] [Retrieve the host part of the HTTP URI.]]
29+
[[`port(h)`] [uint16_t] [Retrieve the port part of the HTTP URI.]]
30+
[[`path(h)`] [S] [Retrieve the path part of the HTTP URI.]]
31+
[[`query(h)`] [S] [Retrieve the query part of the HTTP URI.]]
32+
[[`fragment(h)`][S] [Retrieve the fragment part of the HTTP URI.]]
33+
]
34+
35+
[endsect] [/ http_uri]

libs/network/doc/intro.qbk

+42-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[/
2-
(C) Copyright 2009 Glyn Matthews.
2+
(C) Copyright 2009, 2010 Glyn Matthews.
33
Distributed under the Boost Software License, Version 1.0.
44
(See accompanying file LICENSE_1_0.txt or copy at
55
http://www.boost.org/LICENSE_1_0.txt).
@@ -9,28 +9,58 @@
99
[section:intro Introduction]
1010

1111
[section:motivation Motivation]
12-
Modern applications that communicate with the web have never been more prevalent, through a range of diverse areas from high performance servers to embedded systems such as smart phones or navigation systems. Such applications often have high performance or small memory footprint requirements for which C++ is the best language option. Currently, there are no network libraries available that use modern object-oriented techniques in C++. __libcurl__ and __mozilla_netlib__ are two widely used libraries in this domain but there are drawbacks to both:
12+
Modern applications that communicate over the internet have never been
13+
more prevalent, ranging through diverse areas such as high performance
14+
servers to embedded systems for smart phones and navigation systems.
1315

14-
* __libcurl__ suffers from poor design and inconsistent behavior in a threaded environment
15-
* __mozilla_netlib__ is too heavily coupled within the Mozilla architecture for practical use as a separate component
16+
Currently, there are no open source network libraries available that
17+
use modern object-oriented techniques in C++. Any developer will
18+
understand the familiar problem of searching for a protocol library
19+
for their project, failing to find anything suitable and too often
20+
having to hand-roll their own.
1621

17-
With the development of __boost_asio__, developing portable network C++ applications has become a very much easier task. What is still lacking is a set of libraries that utilise __boost_asio__ in order to provide application level support so that C++ developers are able to develop internet and distributed applications more effectively.
22+
By leveraging __boost__, and in particular __boost_asio__, developers
23+
can create portable network C++ applications much more easily. What
24+
is still lacking is a set of libraries that utilise __boost_asio__ in
25+
order to provide application level support so that C++ developers are
26+
able to develop internet and distributed applications more
27+
effectively. This is the niche that the developers of the __cnl__ see
28+
their project filling.
1829

19-
[endsect]
30+
[endsect] [/motivation]
2031

2132
[section:objectives Objectives]
2233
The objectives of the __cnl__ are to:
2334

2435
* develop a high quality, portable, easy to use C++ networking library
2536
* enable developers to easily extend the library
26-
* lower the barrier to entry for cross-platform network-aware C++ applications
37+
* lower the barrier to entry for cross-platform, network-aware C++
38+
applications
2739

28-
The goal of __cnl__ has never been to build a fully-featured web server - there are plenty of excellent options already available. The niche that this library targets is for light-weight networking functionality for C++ applications that have demanding performance requirements or memory constraints, but that also need to be portable. This type of application is becoming increasingly common as software becomes more distributed, and applications need to communicate with services.
40+
The goal of the __cnl__ has never been to build a fully-featured web
41+
server - there are plenty of excellent options already available.
42+
This project targets light-weight networking functionality for C++
43+
applications that have demanding performance requirements or memory
44+
constraints, but that also need to be portable. This type of
45+
application is becoming increasingly common as software becomes more
46+
distributed, and applications need to run on a wide range of devices.
2947

30-
While many languages provide direct library support for high level network programming, this feature is missing in C++. Therefore, this library has been developed with the intention of eventually being submitted to __boost__, a collection of general, high quality libraries for C++ developers.
48+
While many languages provide direct library support for high level
49+
network programming, this feature is missing in standard C++.
50+
Therefore, this library has been developed with the intention of
51+
eventually being submitted to __boost__.
3152

32-
Eventually, __cnl__ will be extended to support many of the application layer protocols such as SMTP, FTP, SOAP, XMPP etc.
53+
Eventually, the __cnl__ will be extended to support many of the
54+
application layer protocols such as SMTP, FTP, SOAP, XMPP etc.
3355

34-
[endsect]
56+
[endsect] [/objectives]
3557

36-
[endsect]
58+
[section:history History]
59+
The __cnl__ was founded by Dean Michael Berris in 2007. Initially it
60+
consisted of a message template and an HTTP client. It found a home
61+
on __sf_cpp_netlib__ but was migrated at the end of 2009 to __github__
62+
where development is actively continued by a committed community.
63+
64+
[endsect] [/history]
65+
66+
[endsect] [/intro]

0 commit comments

Comments
 (0)