MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetResultFromHTTPStatus

Method GetResultFromHTTPStatus

Sources/Shared/IO/WebRequest.cpp:396–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394 }
395
396 WebRequest::Result WebRequestImpl::GetResultFromHTTPStatus(const WebResponseImplPtr& resp)
397 {
398 DEATH_ASSERT(resp, "Cannot be called with an uninitialized object", Result::Error("No response object"_s));
399
400 const std::int32_t status = resp->GetStatus();
401
402 if (status == 401 || status == 407) {
403 return Result::Unauthorized(resp->GetStatusText());
404 } else if (status >= 400) {
405 char errorMessage[64];
406 std::size_t length = formatInto(errorMessage, "Error {} ({})", status, resp->GetStatusText());
407 return Result::Error({ errorMessage, length });
408 } else {
409 return Result::Ok(WebRequest::State::Completed);
410 }
411 }
412
413 void WebRequestImpl::SetData(StringView text, StringView contentType)
414 {

Callers

nothing calls this directly

Calls 4

DEATH_ASSERTFunction · 0.85
formatIntoFunction · 0.85
GetStatusMethod · 0.45
GetStatusTextMethod · 0.45

Tested by

no test coverage detected