diff options
| author | Stefan Boberg <[email protected]> | 2026-02-27 13:57:18 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-02-27 13:57:18 +0100 |
| commit | 226ba2cf432ae6c0a787c6156a172f343fc71887 (patch) | |
| tree | cd6267862c609faa7a85d8fde850b787d1128638 /src/zenhttp/clients/httpclientcpr.cpp | |
| parent | add support in http client to accept multi-range responses (#788) (diff) | |
| download | zen-226ba2cf432ae6c0a787c6156a172f343fc71887.tar.xz zen-226ba2cf432ae6c0a787c6156a172f343fc71887.zip | |
MeasureLatency now bails out quickly if it experiences a connection error (#789)
previously it would stall some 40s in this case
Diffstat (limited to 'src/zenhttp/clients/httpclientcpr.cpp')
| -rw-r--r-- | src/zenhttp/clients/httpclientcpr.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/zenhttp/clients/httpclientcpr.cpp b/src/zenhttp/clients/httpclientcpr.cpp index 6bc63db09..90dcfacbb 100644 --- a/src/zenhttp/clients/httpclientcpr.cpp +++ b/src/zenhttp/clients/httpclientcpr.cpp @@ -23,6 +23,21 @@ CreateCprHttpClient(std::string_view BaseUri, const HttpClientSettings& Connecti static std::atomic<uint32_t> HttpClientRequestIdCounter{0}; +bool +HttpClient::ErrorContext::IsConnectionError() const +{ + switch (static_cast<cpr::ErrorCode>(ErrorCode)) + { + case cpr::ErrorCode::CONNECTION_FAILURE: + case cpr::ErrorCode::OPERATION_TIMEDOUT: + case cpr::ErrorCode::HOST_RESOLUTION_FAILURE: + case cpr::ErrorCode::PROXY_RESOLUTION_FAILURE: + return true; + default: + return false; + } +} + // If we want to support different HTTP client implementations then we'll need to make this more abstract HttpClientError::ResponseClass |