StatusCode.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#include "squid.h"
10#include "debug/Stream.h"
11#include "http/StatusCode.h"
12#include "SquidConfig.h"
13
14const char *
16{
17 switch (status) {
18
19 // 000
20 case Http::scNone:
21 return "Init"; /* we init .status with code 0 */
22 break;
23
24 // 100-199
26 return "Continue";
27 break;
28
30 return "Switching Protocols";
31 break;
32
34 return "Processing";
35 break;
36
37 case Http::scEarlyHints: // 103
38 return "Early Hints";
39 break;
40
41 // 200-299
42 case Http::scOkay:
43 return "OK";
44 break;
45
46 case Http::scCreated:
47 return "Created";
48 break;
49
51 return "Accepted";
52 break;
53
55 return "Non-Authoritative Information";
56 break;
57
59 return "No Content";
60 break;
61
63 return "Reset Content";
64 break;
65
67 return "Partial Content";
68 break;
69
71 return "Multi-Status";
72 break;
73
75 return "Already Reported";
76 break;
77
78 case Http::scImUsed:
79 return "IM Used";
80 break;
81
82 // 300-399
84 return "Multiple Choices";
85 break;
86
88 return "Moved Permanently";
89 break;
90
91 case Http::scFound:
92 return "Found";
93 break;
94
96 return "See Other";
97 break;
98
100 return "Not Modified";
101 break;
102
103 case Http::scUseProxy:
104 return "Use Proxy";
105 break;
106
108 return "Temporary Redirect";
109 break;
110
112 return "Permanent Redirect";
113 break;
114
115 // 400-499
117 return "Bad Request";
118 break;
119
121 return "Unauthorized";
122 break;
123
125 return "Payment Required";
126 break;
127
129 return "Forbidden";
130 break;
131
132 case Http::scNotFound:
133 return "Not Found";
134 break;
135
137 return "Method Not Allowed";
138 break;
139
141 return "Not Acceptable";
142 break;
143
145 return "Proxy Authentication Required";
146 break;
147
149 return "Request Timeout";
150 break;
151
152 case Http::scConflict:
153 return "Conflict";
154 break;
155
156 case Http::scGone:
157 return "Gone";
158 break;
159
161 return "Length Required";
162 break;
163
165 return "Precondition Failed";
166 break;
167
169 return "Content Too Large";
170 break;
171
173 return "URI Too Long";
174 break;
175
177 return "Unsupported Media Type";
178 break;
179
181 return "Requested Range Not Satisfiable";
182 break;
183
185 return "Expectation Failed";
186 break;
187
189 return "Misdirected Request";
190 break;
191
193 return "Unprocessable Entity";
194 break;
195
196 case Http::scLocked:
197 return "Locked";
198 break;
199
201 return "Failed Dependency";
202 break;
203
205 return "Upgrade Required";
206 break;
207
209 return "Precondition Required";
210 break;
211
213 return "Too Many Requests";
214 break;
215
217 return "Request Header Fields Too Large";
218 break;
219
221 return "Unavailable For Legal Reasons";
222 break;
223
224 // 500-599
226 return "Internal Server Error";
227 break;
228
230 return "Not Implemented";
231 break;
232
234 return "Bad Gateway";
235 break;
236
238 return "Service Unavailable";
239 break;
240
242 return "Gateway Timeout";
243 break;
244
246 return "HTTP Version not supported";
247 break;
248
250 return "Variant Also Negotiates";
251 break;
252
254 return "Insufficient Storage";
255 break;
256
258 return "Loop Detected";
259 break;
260
262 return "Not Extended";
263 break;
264
266 return "Network Authentication Required";
267 break;
268
269 // 600+
272 [[fallthrough]];
273
274 default:
275 debugs(57, 3, "Unassigned HTTP status code: " << status);
276 }
277 return "Unassigned";
278}
279
280bool
282{
283 switch (s) {
284
285 case scBadGateway:
286 case scGatewayTimeout:
287 return true;
288
289 case scForbidden:
291 case scNotImplemented:
293 return Config.retry.onerror;
294
295 default:
296 return false;
297 }
298
299 /* NOTREACHED */
300}
301
class SquidConfig Config
Definition: SquidConfig.cc:12
struct SquidConfig::@110 retry
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
StatusCode
Definition: StatusCode.h:20
@ scAccepted
Definition: StatusCode.h:28
@ scProcessing
Definition: StatusCode.h:24
@ scVariantAlsoNegotiates
Definition: StatusCode.h:77
@ scInsufficientStorage
Definition: StatusCode.h:78
@ scNetworkAuthenticationRequired
Definition: StatusCode.h:81
@ scUriTooLong
Definition: StatusCode.h:58
@ scImUsed
Definition: StatusCode.h:35
@ scGone
Definition: StatusCode.h:54
@ scGatewayTimeout
Definition: StatusCode.h:75
@ scNotAcceptable
Definition: StatusCode.h:50
@ scHeaderTooLarge
Definition: StatusCode.h:87
@ scLocked
Definition: StatusCode.h:64
@ scUseProxy
Definition: StatusCode.h:41
@ scTooManyRequests
Definition: StatusCode.h:68
@ scNotExtended
Definition: StatusCode.h:80
@ scForbidden
Definition: StatusCode.h:47
@ scResetContent
Definition: StatusCode.h:31
@ scUnauthorized
Definition: StatusCode.h:45
@ scNotImplemented
Definition: StatusCode.h:72
@ scUnsupportedMediaType
Definition: StatusCode.h:59
@ scUnprocessableEntity
Definition: StatusCode.h:63
@ scFound
Definition: StatusCode.h:38
@ scMultipleChoices
Definition: StatusCode.h:36
@ scInternalServerError
Definition: StatusCode.h:71
@ scHttpVersionNotSupported
Definition: StatusCode.h:76
@ scBadRequest
Definition: StatusCode.h:44
@ scAlreadyReported
Definition: StatusCode.h:34
@ scCreated
Definition: StatusCode.h:27
@ scInvalidHeader
Definition: StatusCode.h:86
@ scConflict
Definition: StatusCode.h:53
@ scFailedDependency
Definition: StatusCode.h:65
@ scExpectationFailed
Definition: StatusCode.h:61
@ scMultiStatus
Definition: StatusCode.h:33
@ scNotFound
Definition: StatusCode.h:48
@ scMethodNotAllowed
Definition: StatusCode.h:49
@ scPermanentRedirect
Definition: StatusCode.h:43
@ scSeeOther
Definition: StatusCode.h:39
@ scRequestTimeout
Definition: StatusCode.h:52
@ scProxyAuthenticationRequired
Definition: StatusCode.h:51
@ scPaymentRequired
Definition: StatusCode.h:46
@ scNone
Definition: StatusCode.h:21
@ scLengthRequired
Definition: StatusCode.h:55
@ scNotModified
Definition: StatusCode.h:40
@ scOkay
Definition: StatusCode.h:26
@ scTemporaryRedirect
Definition: StatusCode.h:42
@ scContinue
Definition: StatusCode.h:22
@ scNoContent
Definition: StatusCode.h:30
@ scUnavailableForLegalReasons
Definition: StatusCode.h:70
@ scRequestedRangeNotSatisfied
Definition: StatusCode.h:60
@ scPreconditionRequired
Definition: StatusCode.h:67
@ scSwitchingProtocols
Definition: StatusCode.h:23
@ scEarlyHints
Definition: StatusCode.h:25
@ scMovedPermanently
Definition: StatusCode.h:37
@ scNonAuthoritativeInformation
Definition: StatusCode.h:29
@ scPreconditionFailed
Definition: StatusCode.h:56
@ scBadGateway
Definition: StatusCode.h:73
@ scUpgradeRequired
Definition: StatusCode.h:66
@ scMisdirectedRequest
Definition: StatusCode.h:62
@ scLoopDetected
Definition: StatusCode.h:79
@ scContentTooLarge
Definition: StatusCode.h:57
@ scRequestHeaderFieldsTooLarge
Definition: StatusCode.h:69
@ scPartialContent
Definition: StatusCode.h:32
@ scServiceUnavailable
Definition: StatusCode.h:74
bool IsReforwardableStatus(StatusCode)
whether to send the request to another peer based on the current response status code
Definition: StatusCode.cc:281
const char * StatusCodeString(const Http::StatusCode status)
Definition: StatusCode.cc:15

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors