/proc/self/cwd/source/common/http/async_client_utility.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "source/common/http/async_client_utility.h" |
2 | | |
3 | | #include "source/common/common/assert.h" |
4 | | |
5 | | namespace Envoy { |
6 | | namespace Http { |
7 | | |
8 | 0 | AsyncClientRequestTracker::~AsyncClientRequestTracker() { |
9 | 0 | for (auto* active_request : active_requests_) { |
10 | 0 | active_request->cancel(); |
11 | 0 | } |
12 | 0 | } |
13 | | |
14 | 0 | void AsyncClientRequestTracker::add(AsyncClient::Request& request) { |
15 | 0 | ASSERT(active_requests_.find(&request) == active_requests_.end(), "request is already tracked."); |
16 | 0 | active_requests_.insert(&request); |
17 | 0 | } |
18 | | |
19 | 0 | void AsyncClientRequestTracker::remove(const AsyncClient::Request& request) { |
20 | | // Notice that use of "const_cast" here is motivated by keeping API convenient for client code. |
21 | | // In the context where remove() will be typically called, request.cancel() is no longer |
22 | | // desirable and therefore get prevented by means of "const" modifier. |
23 | 0 | auto it = active_requests_.find(const_cast<AsyncClient::Request*>(&request)); |
24 | | // Support a use case where request callbacks might get called prior to a request handle |
25 | | // is returned from AsyncClient::send(). |
26 | 0 | if (it != active_requests_.end()) { |
27 | 0 | active_requests_.erase(it); |
28 | 0 | } |
29 | 0 | } |
30 | | |
31 | | } // namespace Http |
32 | | } // namespace Envoy |