Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8bad17

Browse files
committed
Continued to work on the HTTP client.
1 parent2012b58 commita8bad17

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

‎http/src/http/v2/client/client.cpp‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ namespace network {
3030

3131
voidwrite_request(const boost::system::error_code &ec);
3232

33+
voidread_response(const boost::system::error_code &ec,
34+
std::size_t bytes_written);
35+
3336
voidread_response_status(const boost::system::error_code &ec,
3437
std::size_t bytes_written);
3538

@@ -78,7 +81,7 @@ namespace network {
7881
}
7982

8083
response_promise_.set_exception(std::make_exception_ptr(
81-
boost::system::system_error(ec)));
84+
std::system_error(ec.value(),std::system_category())));
8285
return;
8386
}
8487

@@ -92,30 +95,48 @@ namespace network {
9295
voidclient::impl::write_request(const boost::system::error_code &ec) {
9396
if (ec) {
9497
response_promise_.set_exception(std::make_exception_ptr(
95-
boost::system::system_error(ec)));
98+
std::system_error(ec.value(),std::system_category())));
9699
return;
97100
}
98101

99102
connection_->async_write(request_,
100103
[=] (const boost::system::error_code &ec,
101104
std::size_t bytes_written) {
102-
read_response_status(ec, bytes_written);
105+
read_response(ec, bytes_written);
103106
});
104107
}
105108

109+
voidclient::impl::read_response(const boost::system::error_code &ec, std::size_t) {
110+
if (ec) {
111+
response_promise_.set_exception(std::make_exception_ptr(
112+
std::system_error(ec.value(),std::system_category())));
113+
return;
114+
}
115+
116+
connection_->async_read_until(response_,
117+
"\r\n",
118+
[=] (const boost::system::error_code &ec,
119+
std::size_t bytes_read) {
120+
read_response_status(ec, bytes_read);
121+
});
122+
}
123+
106124
voidclient::impl::read_response_status(const boost::system::error_code &ec,
107125
std::size_t) {
108126
if (ec) {
109127
response_promise_.set_exception(std::make_exception_ptr(
110-
boost::system::system_error(ec)));
128+
std::system_error(ec.value(),std::system_category())));
111129
return;
112130
}
113131

132+
std::istreamis(&response_);
133+
std::string status;
134+
std::getline(is, status);
135+
114136
connection_->async_read_until(response_,
115137
"\r\n",
116138
[=] (const boost::system::error_code &ec,
117139
std::size_t bytes_read) {
118-
// fill headers
119140
read_response_headers(ec, bytes_read);
120141
});
121142
}
@@ -124,10 +145,11 @@ namespace network {
124145
std::size_t) {
125146
if (ec) {
126147
response_promise_.set_exception(std::make_exception_ptr(
127-
boost::system::system_error(ec)));
148+
std::system_error(ec.value(),std::system_category())));
128149
return;
129150
}
130151

152+
// fill headers
131153
connection_->async_read_until(response_,
132154
"\r\n\r\n",
133155
[=] (const boost::system::error_code &ec,

‎http/src/http/v2/client/client_errors.cpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ namespace network {
3939
return"Requires HTTP or HTTPS URL.";
4040
case client_error::resolver_error:
4141
return"Unable to resolve host";
42-
case client_error::connection_timeout:
43-
return"Connection timeout.";
44-
case client_error::https_not_supported:
45-
return"HTTPS is not supported.";
4642
default:
4743
break;
4844
}

‎http/src/network/http/v2/client/client.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace network {
236236
* \ingroup http_client
237237
* \class client network/http/v2/client/client.hpp
238238
* \brief A class that encapsulates the operations and methods
239-
* for communicating with an HTTPservier.
239+
* for communicating with an HTTPserver.
240240
*/
241241
classclient {
242242

‎http/src/network/http/v2/client/client_errors.hpp‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ namespace network {
3232

3333
// connection
3434
host_not_found,
35-
connection_timeout,
36-
https_not_supported,
3735

3836
// response
39-
invalid_version,
40-
invalid_status,
41-
invalid_status_message,
42-
invalid_header,
37+
invalid_response,
4338
};
4439

4540
/**

‎http/src/network/http/v2/status.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ namespace network {
8282
}// namespace http
8383
}// namespace network
8484

85+
#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
8586
namespacestd {
8687
template<>
8788
structhash<network::http::v2::status::code> {
@@ -91,6 +92,7 @@ namespace std {
9192
}
9293
};
9394
}// namespace std
95+
#endif// !defined(DOXYGEN_SHOULD_SKIP_THIS)
9496

9597
namespacenetwork {
9698
namespacehttp {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp