File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ sudo apt-get install libssl-dev
33
33
通过命令行编译:
34
34
35
35
``` bash
36
+ cd cpp-netlib-0.12.0-final
36
37
mkdir build
37
38
cd build
38
39
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ int main() {
11
11
try {
12
12
// ! 1. request
13
13
// client
14
- http::client client;
14
+ http::client::options options;
15
+ // set timeout
16
+ http::client client (options.timeout (2 ));
15
17
// make url
16
18
uri::uri url;
17
19
url << uri::scheme (" http" ) << uri::host (" 127.0.0.1:12345" ) << uri::path (" /cpp-netlib" );
Original file line number Diff line number Diff line change @@ -50,15 +50,15 @@ struct hello_world {
50
50
{" Content-Type" , " text/plain" },
51
51
{" From" , " server-demo" },
52
52
{" Content-Length" , " 0" }};
53
+ // 更新content-length
54
+ std::string body = " hello !!!" ;
55
+ headers[3 ].value = std::to_string (body.length ());
53
56
54
57
// status
55
58
connection->set_status (server::connection::ok);
56
59
// headers
57
60
connection->set_headers (boost::make_iterator_range (headers, headers + 4 ));
58
61
59
- // 更新content-length
60
- std::string body = " hello !!!" ;
61
- headers[3 ].value = std::to_string (body.length ());
62
62
// body
63
63
connection->write (body);
64
64
}
You can’t perform that action at this time.
0 commit comments