ladybird/Libraries/LibRequests/NetworkError.h
Timothy Flynn 3663e12585 RequestServer: Do not request partial content for failed cache reads
This effectively reverts 9b8f6b8108.

I misunderstood what Chrome was doing here - they will issue a range
request only for what they call "sparse" cache entries. These entries
are basically used to cache partial large file, e.g. a multi-gigabyte
video. If they hit a legitimate read error, they will fail the request
with a ERR_CACHE_READ_FAILURE status.

We will now (again) fail with a network error when a cache read fails.
2025-11-21 08:48:42 +01:00

60 lines
1.7 KiB
C++

/*
* Copyright (c) 2024, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringView.h>
namespace Requests {
enum class NetworkError {
UnableToResolveProxy,
UnableToResolveHost,
UnableToConnect,
TimeoutReached,
TooManyRedirects,
SSLHandshakeFailed,
SSLVerificationFailed,
MalformedUrl,
InvalidContentEncoding,
RequestServerDied,
CacheReadFailed,
Unknown,
};
constexpr StringView network_error_to_string(NetworkError network_error)
{
switch (network_error) {
case NetworkError::UnableToResolveProxy:
return "Unable to resolve proxy"sv;
case NetworkError::UnableToResolveHost:
return "Unable to resolve host"sv;
case NetworkError::UnableToConnect:
return "Unable to connect"sv;
case NetworkError::TimeoutReached:
return "Timeout reached"sv;
case NetworkError::TooManyRedirects:
return "Too many redirects"sv;
case NetworkError::SSLHandshakeFailed:
return "SSL handshake failed"sv;
case NetworkError::SSLVerificationFailed:
return "SSL verification failed"sv;
case NetworkError::MalformedUrl:
return "The URL is not formatted properly"sv;
case NetworkError::InvalidContentEncoding:
return "Response could not be decoded with its Content-Encoding"sv;
case NetworkError::RequestServerDied:
return "RequestServer is currently unavailable"sv;
case NetworkError::CacheReadFailed:
return "RequestServer encountered an error reading a cached HTTP response"sv;
case NetworkError::Unknown:
return "An unexpected network error occurred"sv;
}
VERIFY_NOT_REACHED();
}
}