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-4Lines changed: 11 additions & 4 deletions
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-16Lines changed: 35 additions & 16 deletions
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).