5#include "../Common/ResultErrorFormatter.h"
12inline ResultErrorFormat formatHttpError(
HttpError error, Span<char> output)
14 ResultErrorFormatter formatter(output);
17 case HttpError::MalformedPercentEscape: formatter.append(
"URL contains a malformed percent escape");
break;
18 case HttpError::DecodedOutputTooSmall: formatter.append(
"Decoded URL output buffer is too small");
break;
19 case HttpError::RequestTargetEmpty: formatter.append(
"HTTP request target is empty");
break;
20 case HttpError::RequestTargetWhitespace: formatter.append(
"HTTP request target contains whitespace");
break;
21 case HttpError::UnsupportedRequestTargetForm: formatter.append(
"HTTP request target form is unsupported");
break;
22 case HttpError::MalformedURL: formatter.append(
"URL syntax is malformed");
break;
23 case HttpError::UnsupportedProtocol: formatter.append(
"URL protocol is unsupported");
break;
24 case HttpError::InvalidURLPath: formatter.append(
"URL path contains invalid whitespace");
break;
25 case HttpError::InvalidURLHost: formatter.append(
"URL host is invalid");
break;
26 case HttpError::InvalidURLUserInfo: formatter.append(
"URL user information is invalid");
break;
27 case HttpError::InvalidIPv6Host: formatter.append(
"URL IPv6 host is invalid");
break;
28 case HttpError::InvalidURLPort: formatter.append(
"URL port is invalid");
break;
29 case HttpError::AllowHeaderOutputTooSmall: formatter.append(
"Allow header output buffer is too small");
break;
30 case HttpError::MultipartDispositionEmpty: formatter.append(
"Multipart Content-Disposition is empty");
break;
31 case HttpError::MultipartDispositionTypeEmpty: formatter.append(
"Multipart disposition type is empty");
break;
32 case HttpError::MultipartBoundaryInvalid: formatter.append(
"Multipart boundary is empty");
break;
33 case HttpError::MultipartBoundaryTooLong: formatter.append(
"Multipart boundary is too long");
break;
34 case HttpError::MultipartBoundaryCandidateTooLong:
35 formatter.append(
"Multipart boundary candidate is too long");
37 case HttpError::MultipartMalformedSyntax: formatter.append(
"Multipart syntax is malformed");
break;
38 case HttpError::MultipartSpanInvalid: formatter.append(
"Multipart parser span is invalid");
break;
39 case HttpError::AuthorizationCredentialsMissing: formatter.append(
"Authorization credentials are missing");
break;
40 case HttpError::AuthorizationNotBearer: formatter.append(
"Authorization scheme is not Bearer");
break;
41 case HttpError::AuthorizationNotBasic: formatter.append(
"Authorization scheme is not Basic");
break;
42 case HttpError::BasicBase64Incomplete: formatter.append(
"Basic credentials have incomplete base64");
break;
43 case HttpError::BasicBase64Invalid: formatter.append(
"Basic credentials have invalid base64");
break;
44 case HttpError::BasicBase64PaddingInvalid: formatter.append(
"Basic credentials have invalid base64 padding");
break;
45 case HttpError::BasicBase64TrailingData: formatter.append(
"Basic credentials have trailing base64 data");
break;
46 case HttpError::BasicDecodeOutputTooSmall: formatter.append(
"Basic credential output buffer is too small");
break;
47 case HttpError::BasicPasswordSeparatorMissing:
48 formatter.append(
"Basic credentials lack a password separator");
50 case HttpError::BasicUsernameContainsColon: formatter.append(
"Basic username contains a colon");
break;
51 case HttpError::AuthorizationOutputTooSmall: formatter.append(
"Authorization output buffer is too small");
break;
52 case HttpError::BearerTokenEmpty: formatter.append(
"Bearer token is empty");
break;
53 case HttpError::BasicCredentialsEmpty: formatter.append(
"Basic credentials are empty");
break;
54 case HttpError::SetCookieHeaderEmpty: formatter.append(
"Set-Cookie header is empty");
break;
55 case HttpError::SetCookieNameValueMissing: formatter.append(
"Set-Cookie name/value pair is missing");
break;
56 case HttpError::SetCookieNameEmpty: formatter.append(
"Set-Cookie name is empty");
break;
57 case HttpError::SetCookieOutputTooSmall: formatter.append(
"Set-Cookie output buffer is too small");
break;
58 case HttpError::CacheControlConflictingVisibility:
59 formatter.append(
"Cache-Control cannot be both public and private");
61 case HttpError::CacheControlOutputTooSmall: formatter.append(
"Cache-Control output buffer is too small");
break;
62 case HttpError::CacheControlNoDirectives: formatter.append(
"Cache-Control has no directives");
break;
63 case HttpError::HeaderStorageExhausted: formatter.append(
"HTTP header storage is exhausted");
break;
64 case HttpError::HeaderSizeLimitExceeded: formatter.append(
"HTTP header size limit is exceeded");
break;
65 case HttpError::HeaderTokenLimitExceeded: formatter.append(
"HTTP header token limit is exceeded");
break;
66 case HttpError::HeaderOutputTooSmall: formatter.append(
"HTTP header output buffer is too small");
break;
67 case HttpError::MultipartBodyOutputTooSmall: formatter.append(
"Multipart body output buffer is too small");
break;
68 case HttpError::ContentLengthFormattingFailed: formatter.append(
"Content-Length formatting failed");
break;
69 case HttpError::MultipartWriterBoundaryEmpty: formatter.append(
"Multipart output boundary is empty");
break;
70 case HttpError::MultipartWriterBoundaryUnsafe: formatter.append(
"Multipart output boundary is unsafe");
break;
71 case HttpError::MultipartWriterBoundaryMissing: formatter.append(
"Multipart output boundary is not set");
break;
72 case HttpError::MultipartWriterFieldNameEmpty: formatter.append(
"Multipart output field name is empty");
break;
73 case HttpError::MultipartWriterFieldNameUnsafe: formatter.append(
"Multipart output field name is unsafe");
break;
74 case HttpError::MultipartWriterFileNameUnsafe: formatter.append(
"Multipart output file name is unsafe");
break;
75 case HttpError::MultipartWriterContentTypeUnsafe:
76 formatter.append(
"Multipart output content type is unsafe");
78 case HttpError::MultipartWriterPartLimitExceeded:
79 formatter.append(
"Multipart output part limit is exceeded");
81 case HttpError::BodyExceedsContentLength: formatter.append(
"HTTP body exceeds Content-Length");
break;
82 case HttpError::BodyFramingHeadersConflict:
83 formatter.append(
"Content-Length conflicts with Transfer-Encoding");
85 case HttpError::TransferEncodingUnsupported: formatter.append(
"HTTP Transfer-Encoding is unsupported");
break;
86 case HttpError::UnexpectedBodyData: formatter.append(
"Unexpected HTTP body data");
break;
87 case HttpError::BodyStreamConsumptionMismatch:
88 formatter.append(
"HTTP body stream consumed an unexpected byte count");
90 case HttpError::ChunkSizeOverflow: formatter.append(
"HTTP chunk size overflows");
break;
91 case HttpError::ChunkSizeInvalid: formatter.append(
"HTTP chunk size is invalid");
break;
92 case HttpError::ChunkHeaderMalformed: formatter.append(
"HTTP chunk header is malformed");
break;
93 case HttpError::ChunkTerminatorMalformed: formatter.append(
"HTTP chunk terminator is malformed");
break;
94 case HttpError::ChunkTrailersUnsupported: formatter.append(
"HTTP chunk trailers are unsupported");
break;
95 case HttpError::ChunkTrailerTerminatorMalformed:
96 formatter.append(
"HTTP chunk trailer terminator is malformed");
98 case HttpError::PipelinedBodyUnsupported: formatter.append(
"Pipelined HTTP body data is unsupported");
break;
99 case HttpError::ChunkHeaderOutputTooSmall: formatter.append(
"HTTP chunk header output buffer is too small");
break;
100 case HttpError::ChunkedDestinationMissing: formatter.append(
"Chunked HTTP output destination is missing");
break;
101 case HttpError::HeadersAlreadySent: formatter.append(
"HTTP headers have already been sent");
break;
102 case HttpError::HeaderStartMissing: formatter.append(
"HTTP message start must precede headers");
break;
103 case HttpError::MessageStartAlreadyWritten: formatter.append(
"HTTP message start has already been written");
break;
104 case HttpError::KeepAliveDisabled: formatter.append(
"HTTP keep-alive is disabled for this connection");
break;
105 case HttpError::ContentLengthTransferEncodingConflict:
106 formatter.append(
"Content-Length conflicts with Transfer-Encoding");
108 case HttpError::DestinationStreamMissing: formatter.append(
"HTTP output destination stream is missing");
break;
109 case HttpError::HeadersNotSent: formatter.append(
"HTTP headers have not been sent");
break;
110 case HttpError::ResponseStatusUnsupported: formatter.append(
"HTTP response status is unsupported");
break;
111 case HttpError::ResponseStatusInvalid: formatter.append(
"HTTP response status must have three digits");
break;
112 case HttpError::ResponseReasonPhraseEmpty: formatter.append(
"HTTP response reason phrase is empty");
break;
113 case HttpError::ResponseReasonPhraseInvalid:
114 formatter.append(
"HTTP response reason phrase contains a line break");
116 case HttpError::ResponseStatusFormattingFailed: formatter.append(
"HTTP response status formatting failed");
break;
117 case HttpError::RedirectStatusInvalid: formatter.append(
"HTTP redirect status must be 3xx");
break;
118 case HttpError::RedirectLocationEmpty: formatter.append(
"HTTP redirect location is empty");
break;
119 case HttpError::ContentEncodingUnsupported: formatter.append(
"HTTP Content-Encoding is unsupported");
break;
120 case HttpError::CompressedBodyEncodingInvalid:
121 formatter.append(
"Compressed HTTP request body requires gzip or deflate");
123 case HttpError::MultipartWriterMissing: formatter.append(
"Multipart request writer is missing");
break;
124 case HttpError::PoolActiveConnectionsRemain:
125 formatter.append(
"HTTP connection pool still has active connections");
127 case HttpError::PoolHeaderStorageEmpty: formatter.append(
"HTTP connection header storage is empty");
break;
128 case HttpError::PoolReadQueueConfigurationInvalid:
129 formatter.append(
"HTTP connection read queue configuration is invalid");
131 case HttpError::PoolBufferQueueConfigurationInvalid:
132 formatter.append(
"HTTP connection buffer queue is smaller than its read queue");
134 case HttpError::PoolReadQueueStorageTooSmall: formatter.append(
"HTTP read queue storage is too small");
break;
135 case HttpError::PoolWriteQueueStorageTooSmall: formatter.append(
"HTTP write queue storage is too small");
break;
136 case HttpError::PoolBufferQueueStorageTooSmall: formatter.append(
"HTTP buffer queue storage is too small");
break;
137 case HttpError::PoolHeaderStorageTooSmall: formatter.append(
"HTTP header storage is too small");
break;
138 case HttpError::PoolStreamStorageTooSmall: formatter.append(
"HTTP stream storage is too small");
break;
139 case HttpError::ParserMethodMalformed: formatter.append(
"HTTP request method is malformed");
break;
140 case HttpError::ParserRequestTargetMalformed: formatter.append(
"HTTP request target is malformed");
break;
141 case HttpError::ParserVersionMalformed: formatter.append(
"HTTP version is malformed");
break;
142 case HttpError::ParserStatusCodeMalformed: formatter.append(
"HTTP response status code is malformed");
break;
143 case HttpError::ParserStatusTextMalformed: formatter.append(
"HTTP response status text is malformed");
break;
144 case HttpError::ParserHeaderNameMalformed: formatter.append(
"HTTP header name is malformed");
break;
145 case HttpError::ParserHeaderValueMalformed: formatter.append(
"HTTP header value is malformed");
break;
146 case HttpError::ParserContentLengthMalformed: formatter.append(
"HTTP Content-Length is malformed");
break;
147 case HttpError::ParserConnectionHeaderMalformed: formatter.append(
"HTTP Connection header is malformed");
break;
148 case HttpError::ParserHeaderTerminatorMalformed: formatter.append(
"HTTP header terminator is malformed");
break;
149 case HttpError::ParserSpanInvalid: formatter.append(
"HTTP parser span is invalid");
break;
150 case HttpError::HeaderBlockIncomplete: formatter.append(
"HTTP header block is incomplete");
break;
151 case HttpError::ServerReadQueueEmpty: formatter.append(
"HTTP server connection read queue is empty");
break;
152 case HttpError::ServerWriteQueueEmpty: formatter.append(
"HTTP server connection write queue is empty");
break;
153 case HttpError::ServerBufferPoolEmpty: formatter.append(
"HTTP server connection buffer pool is empty");
break;
154 case HttpError::ServerResizeAddressChanged:
155 formatter.append(
"HTTP server connection storage address changed");
157 case HttpError::ServerResizeActiveConnection:
158 formatter.append(
"HTTP server resize would remove an active connection");
160 case HttpError::ServerAlreadyStarted: formatter.append(
"HTTP server is already started or stopping");
break;
161 case HttpError::ServerNotInitialized: formatter.append(
"HTTP server has no initialized connections");
break;
162 case HttpError::ServerExternalListenerRequired:
163 formatter.append(
"HTTP server has no active external listener");
165 case HttpError::ServerConnectionSlotUnavailable:
166 formatter.append(
"HTTP server connection slot is unavailable");
168 case HttpError::ServerStopRequired: formatter.append(
"HTTP server must stop before closing");
break;
169 case HttpError::ServerNotStarted: formatter.append(
"HTTP server is not started");
break;
170 case HttpError::ServerNotStopping: formatter.append(
"HTTP server is not stopping");
break;
171 case HttpError::ServerDataListenerUnavailable:
172 formatter.append(
"HTTP server readable data listener is unavailable");
174 case HttpError::FileServerAlreadyInitialized: formatter.append(
"HTTP file server is already initialized");
break;
175 case HttpError::FileServerDirectoryUnavailable:
176 formatter.append(
"HTTP file server directory is unavailable");
178 case HttpError::FileServerRequestTargetNotPath: formatter.append(
"HTTP file request target is not a path");
break;
179 case HttpError::FileServerPathEmpty: formatter.append(
"HTTP file path is empty");
break;
180 case HttpError::FileServerPathCharacterInvalid:
181 formatter.append(
"HTTP file path contains an invalid character");
183 case HttpError::FileServerDotSegment: formatter.append(
"HTTP file path contains a dot segment");
break;
184 case HttpError::FileServerParentSegment: formatter.append(
"HTTP file path contains a parent segment");
break;
185 case HttpError::FileServerDateConversionFailed: formatter.append(
"HTTP date conversion failed");
break;
186 case HttpError::FileServerDateOutputTooSmall: formatter.append(
"HTTP date output buffer is too small");
break;
187 case HttpError::FileServerContentRangeOutputTooSmall:
188 formatter.append(
"Content-Range output buffer is too small");
190 case HttpError::FileServerETagOutputTooSmall: formatter.append(
"ETag output buffer is too small");
break;
191 case HttpError::ClientClosed: formatter.append(
"HTTP client was closed");
break;
192 case HttpError::ClientBodyStreamMissing: formatter.append(
"HTTP client request body stream is missing");
break;
193 case HttpError::ClientNotInitialized: formatter.append(
"HTTP client is not initialized");
break;
194 case HttpError::ClientConnectionUpgraded: formatter.append(
"HTTP client connection is upgraded");
break;
195 case HttpError::ClientRequestInProgress: formatter.append(
"HTTP client request is already in progress");
break;
196 case HttpError::ClientUpgradeHeadersMissing: formatter.append(
"HTTP upgrade response headers are missing");
break;
197 case HttpError::ClientUpgradeStatusInvalid: formatter.append(
"HTTP upgrade response status is not 101");
break;
198 case HttpError::ClientUserInfoUnsupported:
199 formatter.append(
"HTTP client URL user information is unsupported");
201 case HttpError::ClientReconnectNotPending: formatter.append(
"HTTP client reconnect is not pending");
break;
202 case HttpError::ClientReconnectListenerUnavailable:
203 formatter.append(
"HTTP client reconnect listener is unavailable");
205 case HttpError::ClientSocketInvalid: formatter.append(
"HTTP client socket is invalid");
break;
206 case HttpError::ClientHttpsTransportMissing:
207 formatter.append(
"HTTP client HTTPS transport adapter is missing");
209 case HttpError::ClientProtocolStorageTooSmall: formatter.append(
"HTTP client protocol storage is too small");
break;
210 case HttpError::ClientHostStorageTooSmall: formatter.append(
"HTTP client host storage is too small");
break;
211 case HttpError::ClientResponseListenerUnavailable:
212 formatter.append(
"HTTP client response listener is unavailable");
214 case HttpError::ClientBodyStreamPoolMismatch:
215 formatter.append(
"HTTP client body stream uses a different buffer pool");
217 case HttpError::ClientTransformReadablePoolMismatch:
218 formatter.append(
"HTTP client body transform readable side uses a different buffer pool");
220 case HttpError::ClientTransformWritablePoolMismatch:
221 formatter.append(
"HTTP client body transform writable side uses a different buffer pool");
223 case HttpError::ClientDecoderListenerUnavailable:
224 formatter.append(
"HTTP response decoder listener is unavailable");
226 case HttpError::ClientInformationalResponseUnsupported:
227 formatter.append(
"HTTP informational response is unsupported by this client");
229 case HttpError::ClientResponseIncomplete: formatter.append(
"HTTP response was incomplete at disconnect");
break;
230 case HttpError::WebSocketBase64OutputTooSmall:
231 formatter.append(
"WebSocket Base64 output buffer is too small");
233 case HttpError::WebSocketBase64LengthInvalid: formatter.append(
"WebSocket Base64 length is invalid");
break;
234 case HttpError::WebSocketBase64PaddingInvalid: formatter.append(
"WebSocket Base64 padding is invalid");
break;
235 case HttpError::WebSocketBase64CharacterInvalid: formatter.append(
"WebSocket Base64 character is invalid");
break;
236 case HttpError::WebSocketBase64DecodeOutputTooSmall:
237 formatter.append(
"WebSocket Base64 decode output buffer is too small");
239 case HttpError::WebSocketSha1ProviderUnavailable:
240 formatter.append(
"WebSocket SHA-1 provider is unavailable");
242 case HttpError::WebSocketSha1ModeInvalid: formatter.append(
"WebSocket SHA-1 mode is invalid");
break;
243 case HttpError::WebSocketSha1DigestSizeInvalid: formatter.append(
"WebSocket SHA-1 digest size is invalid");
break;
244 case HttpError::WebSocketNonceLengthInvalid: formatter.append(
"WebSocket nonce length must be 16 bytes");
break;
245 case HttpError::WebSocketClientKeyLengthInvalid: formatter.append(
"WebSocket client key length is invalid");
break;
246 case HttpError::WebSocketClientKeyDecodedLengthInvalid:
247 formatter.append(
"WebSocket decoded client key length is invalid");
249 case HttpError::WebSocketUpgradeStatusInvalid:
250 formatter.append(
"WebSocket upgrade response status is not 101");
252 case HttpError::WebSocketUpgradeHeaderInvalid: formatter.append(
"WebSocket Upgrade header is invalid");
break;
253 case HttpError::WebSocketConnectionHeaderInvalid: formatter.append(
"WebSocket Connection header is invalid");
break;
254 case HttpError::WebSocketAcceptHeaderInvalid:
255 formatter.append(
"WebSocket Sec-WebSocket-Accept header is invalid");
257 case HttpError::WebSocketServerRequestNotAcceptable:
258 formatter.append(
"WebSocket server request is not acceptable");
260 case HttpError::WebSocketRejectAcceptedRequest:
261 formatter.append(
"Accepted WebSocket request cannot be rejected");
263 case HttpError::WebSocketFrameReservedBitsUnsupported:
264 formatter.append(
"WebSocket frame reserved bits are unsupported");
266 case HttpError::WebSocketOpcodeUnsupported: formatter.append(
"WebSocket frame opcode is unsupported");
break;
267 case HttpError::WebSocketFrameLengthInvalid: formatter.append(
"WebSocket frame payload length is invalid");
break;
268 case HttpError::WebSocketFramePayloadProgressInvalid:
269 formatter.append(
"WebSocket frame payload parsing made no progress");
271 case HttpError::WebSocketFrameMaskInvalid:
272 formatter.append(
"WebSocket frame masking does not match the endpoint role");
274 case HttpError::WebSocketControlFrameFragmented:
275 formatter.append(
"WebSocket control frame must not be fragmented");
277 case HttpError::WebSocketControlFrameTooLarge:
278 formatter.append(
"WebSocket control frame payload is too large");
280 case HttpError::WebSocketContinuationUnexpected:
281 formatter.append(
"WebSocket continuation frame is unexpected");
283 case HttpError::WebSocketContinuationExpected: formatter.append(
"WebSocket continuation frame is expected");
break;
284 case HttpError::WebSocketFrameAlreadyInProgress: formatter.append(
"WebSocket frame is already in progress");
break;
285 case HttpError::WebSocketFrameHeaderOutputTooSmall:
286 formatter.append(
"WebSocket frame header output buffer is too small");
288 case HttpError::WebSocketFrameMissing: formatter.append(
"WebSocket frame is not in progress");
break;
289 case HttpError::WebSocketFramePayloadExceedsLength:
290 formatter.append(
"WebSocket frame payload exceeds its declared length");
292 case HttpError::WebSocketFramePayloadIncomplete: formatter.append(
"WebSocket frame payload is incomplete");
break;
293 case HttpError::WebSocketMessageMissing: formatter.append(
"WebSocket message is not in progress");
break;
294 case HttpError::WebSocketMessageStorageTooSmall: formatter.append(
"WebSocket message storage is too small");
break;
295 case HttpError::WebSocketMaskKeyMissing: formatter.append(
"WebSocket client mask key is missing");
break;
296 case HttpError::WebSocketFramePayloadLengthMismatch:
297 formatter.append(
"WebSocket frame payload length differs from its header");
299 case HttpError::WebSocketFrameOutputTooSmall: formatter.append(
"WebSocket frame output buffer is too small");
break;
300 case HttpError::WebSocketDataOpcodeRequired: formatter.append(
"WebSocket data opcode is required");
break;
301 case HttpError::WebSocketCloseStatusRequired:
302 formatter.append(
"WebSocket close reason requires a status code");
304 case HttpError::WebSocketClosePayloadMalformed: formatter.append(
"WebSocket close payload is malformed");
break;
305 case HttpError::WebSocketControlBackpressure:
306 formatter.append(
"WebSocket automatic control frame is still pending");
308 case HttpError::WebSocketAutomaticControlOutputTooSmall:
309 formatter.append(
"WebSocket automatic control storage is too small");
311 case HttpError::WebSocketTransportInvalid: formatter.append(
"WebSocket transport is invalid");
break;
312 case HttpError::WebSocketPumpListenerUnavailable: formatter.append(
"WebSocket pump listener is unavailable");
break;
313 case HttpError::WebSocketPumpNotAttached: formatter.append(
"WebSocket pump is not attached");
break;
314 case HttpError::WebSocketFrameEmpty: formatter.append(
"WebSocket encoded frame is empty");
break;
315 case HttpError::WebSocketHubFull: formatter.append(
"WebSocket hub has no free client slot");
break;
316 case HttpError::WebSocketHubClientIndexInvalid: formatter.append(
"WebSocket hub client index is invalid");
break;
317 default:
return ResultErrorFormatter::failure(ResultErrorFormatStatus::UnknownError, output);
319 return formatter.finish();
322inline ResultErrorFormat formatHttpError(Result result, Span<char> output)
325 return ResultErrorFormatter::failure(ResultErrorFormatStatus::NotAnError, output);
326 if (result.category() != HttpResultCategory)
327 return ResultErrorFormatter::failure(ResultErrorFormatStatus::ForeignCategory, output);
328 return formatHttpError(
static_cast<HttpError>(result.errorValue()), output);
HttpError
Stable portable failures owned by Http.
Definition HttpError.h:15