admin/logs: show explanation for http status codes #908

Massimo Melina committed Feb 19, 2025 at 20:02 UTC c873041205e545c2bdd0e66390fd7edf2cfc7bb2
2 files changed +69 -1
admin/src/LogsPage.ts
+4 -1
@@ -1,6 +1,7 @@
1 // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3 -import { createElement as h, Fragment, ReactNode, useEffect, useMemo, useState } from 'react';
3 +import { createElement as h, Fragment, ReactNode, useEffect, useMemo, useState } from 'react'
4 +import httpCodes from './httpCodes'
5 import { Box, Tab, Tabs } from '@mui/material'
6 import { API_URL, apiCall, useApi, useApiList } from './api'
7 import { DataTable, DataTableProps } from './DataTable'
@@ -263,6 +264,8 @@ export function LogFile({ file, footerSide, hidden, limit, filter, ...rest }: Lo
264 type: 'number',
265 width: 70,
266 hideUnder: 'xl',
267 + renderCell: ({ value }) => hTooltip(prefix(value + ' - ', httpCodes[value]) || "Unknown", undefined,
268 + h(Box, { bgcolor: '#888a', color: '#fff', borderRadius: '.3em', p: '.05em .2em' }, value))
269 },
270 {
271 field: 'length',
admin/src/httpCodes.ts new
+65
@@ -0,0 +1,65 @@
1 +export default {
2 + 100: "Continue: the initial headers were received; continue with the request body",
3 + 101: "Switching Protocols: the server is switching protocols as requested",
4 + 102: "Processing: the server is processing the request but a complete response isn’t ready yet",
5 + 103: "Early Hints: preliminary headers are being sent before the final response",
6 + 200: "OK: response sent",
7 + 201: "Created: a new resource was created successfully",
8 + 202: "Accepted: the request has been accepted for processing but isn’t complete yet",
9 + 203: "Non-Authoritative Information: the response contains modified information from a third party",
10 + 204: "No Content: the request succeeded but there’s no content to return",
11 + 205: "Reset Content: the request succeeded; please reset your view",
12 + 206: "Partial Content: only part of the resource is being returned as requested",
13 + 207: "Multi-Status: the response contains several status codes for different parts of the request",
14 + 208: "Already Reported: the resource has already been reported in a previous response",
15 + 226: "IM Used: the server fulfilled the request using instance manipulations",
16 + 300: "Multiple Choices: several options are available for the requested resource",
17 + 301: "Moved Permanently: the resource has been permanently moved to a new URL",
18 + 302: "Found: the resource is temporarily located at a different URL",
19 + 303: "See Other: the requested resource can be found using GET at another URL",
20 + 304: "Not Modified: the browser was asked to use its cached version, and the file was not actually sent",
21 + 305: "Use Proxy: the requested resource must be accessed through the specified proxy",
22 + 306: "Switch Proxy: this code is no longer used but is reserved for future use",
23 + 307: "Temporary Redirect: the resource is temporarily available at a different URL; use the original for future requests",
24 + 308: "Permanent Redirect: the resource has been permanently moved to another URL",
25 + 400: "Bad Request: the request is malformed or contains invalid parameters",
26 + 401: "Unauthorized: authentication is required and was either not provided or failed",
27 + 402: "Payment Required: payment is required to access this resource (reserved for future use)",
28 + 403: "Forbidden: the server understands the request but refuses to authorize it",
29 + 404: "Not Found: the requested resource could not be found",
30 + 405: "Method Not Allowed: the HTTP method used isn’t allowed for this resource",
31 + 406: "Not Acceptable: the resource can’t produce content acceptable according to the request",
32 + 407: "Proxy Authentication Required: proxy authentication is required to access the resource",
33 + 408: "Request Timeout: the server timed out waiting for the request",
34 + 409: "Conflict: the request couldn’t be processed due to a conflict",
35 + 410: "Gone: the requested resource is no longer available",
36 + 411: "Length Required: the request didn’t include the required content length",
37 + 412: "Precondition Failed: one or more conditions in the request header failed",
38 + 413: "Payload Too Large: the request payload is too large for the server to process",
39 + 414: "URI Too Long: the URL provided is too long",
40 + 415: "Unsupported Media Type: the media type is not supported by the server",
41 + 416: "Range Not Satisfiable: the requested range cannot be fulfilled by the server",
42 + 417: "Expectation Failed: the server can’t meet the expectations in the request’s header",
43 + 418: "I'm a Teapot: this code is a humorous reference and not meant for real use",
44 + 421: "Misdirected Request: the request was sent to a server that can’t produce a response",
45 + 422: "Unprocessable Entity: the request was well-formed but contains semantic errors",
46 + 423: "Locked: the resource is locked and can’t be accessed",
47 + 424: "Failed Dependency: the request failed because a previous request did not succeed",
48 + 425: "Too Early: the server refuses to process the request to prevent replay attacks",
49 + 426: "Upgrade Required: the client should switch to a different protocol",
50 + 428: "Precondition Required: the server requires the request to be conditional",
51 + 429: "Too Many Requests: too many requests have been sent in a short period",
52 + 431: "Request Header Fields Too Large: the request’s header fields are too large",
53 + 451: "Unavailable For Legal Reasons: the resource is unavailable due to legal restrictions",
54 + 500: "Internal Server Error: the server encountered an unexpected error",
55 + 501: "Not Implemented: the server does not support the requested functionality",
56 + 502: "Bad Gateway: the server received an invalid response from an upstream server",
57 + 503: "Service Unavailable: the server is currently unable to handle the request",
58 + 504: "Gateway Timeout: the server did not receive a timely response from an upstream server",
59 + 505: "HTTP Version Not Supported: the server does not support the HTTP version used",
60 + 506: "Variant Also Negotiates: a circular reference was detected during content negotiation",
61 + 507: "Insufficient Storage: the server is unable to store the requested resource",
62 + 508: "Loop Detected: the server detected an infinite loop while processing the request",
63 + 510: "Not Extended: additional extensions are needed to fulfill the request",
64 + 511: "Network Authentication Required: network access requires proper authentication"
65 +} as { [code: number | string]: string }
\ No newline at end of file