File tree 1 file changed +20
-0
lines changed
libs/network/doc/reference
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,26 @@ happens on a different thread.
105
105
dedicated to that request. The client does not re-cycle connections and uses
106
106
a one-request-one-connection model.
107
107
108
+ When an asynchronous client object is destroyed, it waits for all pending
109
+ asynchronous operations to finish. Errors encountered during operations on
110
+ retrieving data from the response objects cause exceptions to be thrown --
111
+ therefore it is best that if a client object is constructed, it should outlive
112
+ the response object or be outside the try-catch block handling the errors from
113
+ operations on responses. In code, usage should look like the following:
114
+
115
+ .. code-block :: c++
116
+
117
+ http::client client;
118
+ try {
119
+ http::client: :response response = client.get("http://www.example.com/");
120
+ std::cout << body(response);
121
+ } catch (std::exception& e) {
122
+ // deal with exceptions here
123
+ }
124
+
125
+ A common mistake is to declare the client inside the try block which invokes
126
+ undefined behavior when errors arise from the handling of response objects.
127
+
108
128
Member Functions
109
129
----------------
110
130
You can’t perform that action at this time.
0 commit comments