You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libs/network/doc/architecture.qbk
+11-4
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,21 @@
7
7
8
8
9
9
[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.
11
13
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.
13
18
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
Copy file name to clipboardExpand all lines: libs/network/doc/http.qbk
+35-16
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,14 @@
1
1
[/
2
-
(C) Copyright 2008, 2009 Glyn Matthews.
2
+
(C) Copyright 2008, 2009, 2010 Glyn Matthews.
3
3
Distributed under the Boost Software License, Version 1.0.
4
4
(See accompanying file LICENSE_1_0.txt or copy at
5
5
http://www.boost.org/LICENSE_1_0.txt).
6
6
]
7
7
8
8
9
9
[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__.
11
12
12
13
#include <boost/network/protocol/http.hpp>
13
14
#include <iostream>
@@ -33,7 +34,8 @@ The __cnl__ provides direct support for HTTP. As a motivating example, here is
33
34
return 0;
34
35
}
35
36
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:
37
39
38
40
[heading HTTP Request]
39
41
@@ -42,7 +44,8 @@ Before walking through exactly what is happening in this example, the principle
42
44
typedef basic_request<tags::default_> request;
43
45
}}}
44
46
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.
46
49
47
50
[heading HTTP Client]
48
51
@@ -51,7 +54,9 @@ The [^request] encapsulates information about the request and the resource.
51
54
typedef basic_client<tags::default_> client;
52
55
}}}
53
56
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.
55
60
56
61
[heading HTTP Response]
57
62
@@ -60,7 +65,8 @@ The [^client] encapsulates the connection-mapping logic between the domain and t
60
65
typedef basic_response<tags::default_> response;
61
66
}}}
62
67
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.
64
70
65
71
[heading Walkthrough]
66
72
@@ -70,17 +76,24 @@ This line frames the request for the resource __boost_org__.
70
76
71
77
http::client client;
72
78
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.
74
81
75
82
http::response response = client.get(request);
76
83
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).
78
86
79
87
There are several advantages to this design:
80
88
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,
@@ -93,8 +106,9 @@ There are several advantages to this design:
93
106
// print response body
94
107
std::cout << body(response) << std::endl;
95
108
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.
98
112
99
113
[heading Using [^http::client]]
100
114
@@ -112,9 +126,14 @@ HTTP features can be enabled by using constructor arguments:
112
126
* [^http::client(http::client::follow_redirect)]
113
127
114
128
[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.
116
132
117
133
[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).
Distributed under the Boost Software License, Version 1.0.
4
4
(See accompanying file LICENSE_1_0.txt or copy at
5
5
http://www.boost.org/LICENSE_1_0.txt).
@@ -9,28 +9,58 @@
9
9
[section:intro Introduction]
10
10
11
11
[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.
13
15
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.
16
21
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.
18
29
19
-
[endsect]
30
+
[endsect] [/motivation]
20
31
21
32
[section:objectives Objectives]
22
33
The objectives of the __cnl__ are to:
23
34
24
35
* develop a high quality, portable, easy to use C++ networking library
25
36
* 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
27
39
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.
29
47
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__.
31
52
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.
33
55
34
-
[endsect]
56
+
[endsect] [/objectives]
35
57
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.
0 commit comments