Some refactoring on the HTTP codebase

This commit is contained in:
2022-05-16 17:16:42 -04:00
parent 6aa01e5b8c
commit 1ac1ab9420
6 changed files with 61 additions and 154 deletions

View File

@@ -215,17 +215,17 @@ public:
}
// Maintain existing outgoing HTTP client requests.
HttpClientResponseVec http_responses;
HttpParserVec http_responses;
for (auto &pair : http_client_channels_) {
HttpClientChannel &htchan = pair.second;
Channel &channel = *htchan.channel_;
if (channel.closed() || (channel.in()->fill() > htchan.parsed_bytes_)) {
HttpClientResponse response;
HttpParser response;
if (!channel.error().empty()) {
response.fail(503, util::ss("Service Unavailable: ", channel.error()));
} else {
htchan.parsed_bytes_ = channel.in()->fill();
response.parse(channel.in()->view(), channel.closed());
response.parse_response(channel.in()->view(), channel.closed());
}
if (response.complete()) {
response.set_request_id(pair.first);
@@ -233,7 +233,7 @@ public:
}
}
}
for (const HttpClientResponse &response : http_responses) {
for (const HttpParser &response : http_responses) {
http_client_channels_.erase(response.request_id());
}
master_->http_responses(http_responses);