1# frozen_string_literal: true 2# :stopdoc: 3# https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 4class Net::HTTPUnknownResponse < Net::HTTPResponse 5 HAS_BODY = true 6 EXCEPTION_TYPE = Net::HTTPError 7end 8class Net::HTTPInformation < Net::HTTPResponse # 1xx 9 HAS_BODY = false 10 EXCEPTION_TYPE = Net::HTTPError 11end 12class Net::HTTPSuccess < Net::HTTPResponse # 2xx 13 HAS_BODY = true 14 EXCEPTION_TYPE = Net::HTTPError 15end 16class Net::HTTPRedirection < Net::HTTPResponse # 3xx 17 HAS_BODY = true 18 EXCEPTION_TYPE = Net::HTTPRetriableError 19end 20class Net::HTTPClientError < Net::HTTPResponse # 4xx 21 HAS_BODY = true 22 EXCEPTION_TYPE = Net::HTTPClientException # for backward compatibility 23end 24class Net::HTTPServerError < Net::HTTPResponse # 5xx 25 HAS_BODY = true 26 EXCEPTION_TYPE = Net::HTTPFatalError # for backward compatibility 27end 28 29class Net::HTTPContinue < Net::HTTPInformation # 100 30 HAS_BODY = false 31end 32class Net::HTTPSwitchProtocol < Net::HTTPInformation # 101 33 HAS_BODY = false 34end 35class Net::HTTPProcessing < Net::HTTPInformation # 102 36 HAS_BODY = false 37end 38class Net::HTTPEarlyHints < Net::HTTPInformation # 103 - RFC 8297 39 HAS_BODY = false 40end 41 42class Net::HTTPOK < Net::HTTPSuccess # 200 43 HAS_BODY = true 44end 45class Net::HTTPCreated < Net::HTTPSuccess # 201 46 HAS_BODY = true 47end 48class Net::HTTPAccepted < Net::HTTPSuccess # 202 49 HAS_BODY = true 50end 51class Net::HTTPNonAuthoritativeInformation < Net::HTTPSuccess # 203 52 HAS_BODY = true 53end 54class Net::HTTPNoContent < Net::HTTPSuccess # 204 55 HAS_BODY = false 56end 57class Net::HTTPResetContent < Net::HTTPSuccess # 205 58 HAS_BODY = false 59end 60class Net::HTTPPartialContent < Net::HTTPSuccess # 206 61 HAS_BODY = true 62end 63class Net::HTTPMultiStatus < Net::HTTPSuccess # 207 - RFC 4918 64 HAS_BODY = true 65end 66class Net::HTTPAlreadyReported < Net::HTTPSuccess # 208 - RFC 5842 67 HAS_BODY = true 68end 69class Net::HTTPIMUsed < Net::HTTPSuccess # 226 - RFC 3229 70 HAS_BODY = true 71end 72 73class Net::HTTPMultipleChoices < Net::HTTPRedirection # 300 74 HAS_BODY = true 75end 76Net::HTTPMultipleChoice = Net::HTTPMultipleChoices 77class Net::HTTPMovedPermanently < Net::HTTPRedirection # 301 78 HAS_BODY = true 79end 80class Net::HTTPFound < Net::HTTPRedirection # 302 81 HAS_BODY = true 82end 83Net::HTTPMovedTemporarily = Net::HTTPFound 84class Net::HTTPSeeOther < Net::HTTPRedirection # 303 85 HAS_BODY = true 86end 87class Net::HTTPNotModified < Net::HTTPRedirection # 304 88 HAS_BODY = false 89end 90class Net::HTTPUseProxy < Net::HTTPRedirection # 305 91 HAS_BODY = false 92end 93# 306 Switch Proxy - no longer unused 94class Net::HTTPTemporaryRedirect < Net::HTTPRedirection # 307 95 HAS_BODY = true 96end 97class Net::HTTPPermanentRedirect < Net::HTTPRedirection # 308 98 HAS_BODY = true 99end 100 101class Net::HTTPBadRequest < Net::HTTPClientError # 400 102 HAS_BODY = true 103end 104class Net::HTTPUnauthorized < Net::HTTPClientError # 401 105 HAS_BODY = true 106end 107class Net::HTTPPaymentRequired < Net::HTTPClientError # 402 108 HAS_BODY = true 109end 110class Net::HTTPForbidden < Net::HTTPClientError # 403 111 HAS_BODY = true 112end 113class Net::HTTPNotFound < Net::HTTPClientError # 404 114 HAS_BODY = true 115end 116class Net::HTTPMethodNotAllowed < Net::HTTPClientError # 405 117 HAS_BODY = true 118end 119class Net::HTTPNotAcceptable < Net::HTTPClientError # 406 120 HAS_BODY = true 121end 122class Net::HTTPProxyAuthenticationRequired < Net::HTTPClientError # 407 123 HAS_BODY = true 124end 125class Net::HTTPRequestTimeout < Net::HTTPClientError # 408 126 HAS_BODY = true 127end 128Net::HTTPRequestTimeOut = Net::HTTPRequestTimeout 129class Net::HTTPConflict < Net::HTTPClientError # 409 130 HAS_BODY = true 131end 132class Net::HTTPGone < Net::HTTPClientError # 410 133 HAS_BODY = true 134end 135class Net::HTTPLengthRequired < Net::HTTPClientError # 411 136 HAS_BODY = true 137end 138class Net::HTTPPreconditionFailed < Net::HTTPClientError # 412 139 HAS_BODY = true 140end 141class Net::HTTPPayloadTooLarge < Net::HTTPClientError # 413 142 HAS_BODY = true 143end 144Net::HTTPRequestEntityTooLarge = Net::HTTPPayloadTooLarge 145class Net::HTTPURITooLong < Net::HTTPClientError # 414 146 HAS_BODY = true 147end 148Net::HTTPRequestURITooLong = Net::HTTPURITooLong 149Net::HTTPRequestURITooLarge = Net::HTTPRequestURITooLong 150class Net::HTTPUnsupportedMediaType < Net::HTTPClientError # 415 151 HAS_BODY = true 152end 153class Net::HTTPRangeNotSatisfiable < Net::HTTPClientError # 416 154 HAS_BODY = true 155end 156Net::HTTPRequestedRangeNotSatisfiable = Net::HTTPRangeNotSatisfiable 157class Net::HTTPExpectationFailed < Net::HTTPClientError # 417 158 HAS_BODY = true 159end 160# 418 I'm a teapot - RFC 2324; a joke RFC 161# 420 Enhance Your Calm - Twitter 162class Net::HTTPMisdirectedRequest < Net::HTTPClientError # 421 - RFC 7540 163 HAS_BODY = true 164end 165class Net::HTTPUnprocessableEntity < Net::HTTPClientError # 422 - RFC 4918 166 HAS_BODY = true 167end 168class Net::HTTPLocked < Net::HTTPClientError # 423 - RFC 4918 169 HAS_BODY = true 170end 171class Net::HTTPFailedDependency < Net::HTTPClientError # 424 - RFC 4918 172 HAS_BODY = true 173end 174# 425 Unordered Collection - existed only in draft 175class Net::HTTPUpgradeRequired < Net::HTTPClientError # 426 - RFC 2817 176 HAS_BODY = true 177end 178class Net::HTTPPreconditionRequired < Net::HTTPClientError # 428 - RFC 6585 179 HAS_BODY = true 180end 181class Net::HTTPTooManyRequests < Net::HTTPClientError # 429 - RFC 6585 182 HAS_BODY = true 183end 184class Net::HTTPRequestHeaderFieldsTooLarge < Net::HTTPClientError # 431 - RFC 6585 185 HAS_BODY = true 186end 187class Net::HTTPUnavailableForLegalReasons < Net::HTTPClientError # 451 - RFC 7725 188 HAS_BODY = true 189end 190# 444 No Response - Nginx 191# 449 Retry With - Microsoft 192# 450 Blocked by Windows Parental Controls - Microsoft 193# 499 Client Closed Request - Nginx 194 195class Net::HTTPInternalServerError < Net::HTTPServerError # 500 196 HAS_BODY = true 197end 198class Net::HTTPNotImplemented < Net::HTTPServerError # 501 199 HAS_BODY = true 200end 201class Net::HTTPBadGateway < Net::HTTPServerError # 502 202 HAS_BODY = true 203end 204class Net::HTTPServiceUnavailable < Net::HTTPServerError # 503 205 HAS_BODY = true 206end 207class Net::HTTPGatewayTimeout < Net::HTTPServerError # 504 208 HAS_BODY = true 209end 210Net::HTTPGatewayTimeOut = Net::HTTPGatewayTimeout 211class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505 212 HAS_BODY = true 213end 214class Net::HTTPVariantAlsoNegotiates < Net::HTTPServerError # 506 215 HAS_BODY = true 216end 217class Net::HTTPInsufficientStorage < Net::HTTPServerError # 507 - RFC 4918 218 HAS_BODY = true 219end 220class Net::HTTPLoopDetected < Net::HTTPServerError # 508 - RFC 5842 221 HAS_BODY = true 222end 223# 509 Bandwidth Limit Exceeded - Apache bw/limited extension 224class Net::HTTPNotExtended < Net::HTTPServerError # 510 - RFC 2774 225 HAS_BODY = true 226end 227class Net::HTTPNetworkAuthenticationRequired < Net::HTTPServerError # 511 - RFC 6585 228 HAS_BODY = true 229end 230 231class Net::HTTPResponse 232 CODE_CLASS_TO_OBJ = { 233 '1' => Net::HTTPInformation, 234 '2' => Net::HTTPSuccess, 235 '3' => Net::HTTPRedirection, 236 '4' => Net::HTTPClientError, 237 '5' => Net::HTTPServerError 238 } 239 CODE_TO_OBJ = { 240 '100' => Net::HTTPContinue, 241 '101' => Net::HTTPSwitchProtocol, 242 '102' => Net::HTTPProcessing, 243 '103' => Net::HTTPEarlyHints, 244 245 '200' => Net::HTTPOK, 246 '201' => Net::HTTPCreated, 247 '202' => Net::HTTPAccepted, 248 '203' => Net::HTTPNonAuthoritativeInformation, 249 '204' => Net::HTTPNoContent, 250 '205' => Net::HTTPResetContent, 251 '206' => Net::HTTPPartialContent, 252 '207' => Net::HTTPMultiStatus, 253 '208' => Net::HTTPAlreadyReported, 254 '226' => Net::HTTPIMUsed, 255 256 '300' => Net::HTTPMultipleChoices, 257 '301' => Net::HTTPMovedPermanently, 258 '302' => Net::HTTPFound, 259 '303' => Net::HTTPSeeOther, 260 '304' => Net::HTTPNotModified, 261 '305' => Net::HTTPUseProxy, 262 '307' => Net::HTTPTemporaryRedirect, 263 '308' => Net::HTTPPermanentRedirect, 264 265 '400' => Net::HTTPBadRequest, 266 '401' => Net::HTTPUnauthorized, 267 '402' => Net::HTTPPaymentRequired, 268 '403' => Net::HTTPForbidden, 269 '404' => Net::HTTPNotFound, 270 '405' => Net::HTTPMethodNotAllowed, 271 '406' => Net::HTTPNotAcceptable, 272 '407' => Net::HTTPProxyAuthenticationRequired, 273 '408' => Net::HTTPRequestTimeout, 274 '409' => Net::HTTPConflict, 275 '410' => Net::HTTPGone, 276 '411' => Net::HTTPLengthRequired, 277 '412' => Net::HTTPPreconditionFailed, 278 '413' => Net::HTTPPayloadTooLarge, 279 '414' => Net::HTTPURITooLong, 280 '415' => Net::HTTPUnsupportedMediaType, 281 '416' => Net::HTTPRangeNotSatisfiable, 282 '417' => Net::HTTPExpectationFailed, 283 '421' => Net::HTTPMisdirectedRequest, 284 '422' => Net::HTTPUnprocessableEntity, 285 '423' => Net::HTTPLocked, 286 '424' => Net::HTTPFailedDependency, 287 '426' => Net::HTTPUpgradeRequired, 288 '428' => Net::HTTPPreconditionRequired, 289 '429' => Net::HTTPTooManyRequests, 290 '431' => Net::HTTPRequestHeaderFieldsTooLarge, 291 '451' => Net::HTTPUnavailableForLegalReasons, 292 293 '500' => Net::HTTPInternalServerError, 294 '501' => Net::HTTPNotImplemented, 295 '502' => Net::HTTPBadGateway, 296 '503' => Net::HTTPServiceUnavailable, 297 '504' => Net::HTTPGatewayTimeout, 298 '505' => Net::HTTPVersionNotSupported, 299 '506' => Net::HTTPVariantAlsoNegotiates, 300 '507' => Net::HTTPInsufficientStorage, 301 '508' => Net::HTTPLoopDetected, 302 '510' => Net::HTTPNotExtended, 303 '511' => Net::HTTPNetworkAuthenticationRequired, 304 } 305end 306 307# :startdoc: 308