From 9eab89ff49c9c12ec57d992077469f10e26904d6 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Sun, 10 Jun 2012 19:06:09 +0900 Subject: [PATCH] * lib/net/http/responses.rb, lib/webrick/httpstatus.rb: Add HTTP response codes added in RFCs 2817 and 4918. * lib/net/http/responses.rb: Rename Net::HTTPMultipleChoice to Net::HTTPMultipleChoices, leaving the former as alias to the latter for backward compatibitily. * lib/net/http/responses.rb: Add comments about unused, still-in-draft and private extension response codes. --- ChangeLog | 12 ++++++++++++ lib/net/http.rb | 8 +++++++- lib/net/http/responses.rb | 46 ++++++++++++++++++++++++++++++++++++++++++--- lib/webrick/httpstatus.rb | 6 ++++++ 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c478ead..0d2e90a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Sun Jun 10 19:04:19 2012 Akinori MUSHA + + * lib/net/http/responses.rb, lib/webrick/httpstatus.rb: Add HTTP + response codes added in RFCs 2817 and 4918. + + * lib/net/http/responses.rb: Rename Net::HTTPMultipleChoice to + Net::HTTPMultipleChoices, leaving the former as alias to the + latter for backward compatibitily. + + * lib/net/http/responses.rb: Add comments about unused, + still-in-draft and private extension response codes. + Mon Jun 11 06:31:33 2012 Tanaka Akira * process.c (rb_proc_exec_n): revert the function removed at r35889. diff --git a/lib/net/http.rb b/lib/net/http.rb index a2a1b93..9521f6c 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -320,8 +320,9 @@ module Net #:nodoc: # HTTPNoContent:: 204 # HTTPResetContent:: 205 # HTTPPartialContent:: 206 + # HTTPMultiStatus:: 207 # HTTPRedirection:: 3xx - # HTTPMultipleChoice:: 300 + # HTTPMultipleChoices:: 300 # HTTPMovedPermanently:: 301 # HTTPFound:: 302 # HTTPSeeOther:: 303 @@ -347,6 +348,10 @@ module Net #:nodoc: # HTTPUnsupportedMediaType:: 415 # HTTPRequestedRangeNotSatisfiable:: 416 # HTTPExpectationFailed:: 417 + # HTTPUnprocessableEntity:: 422 + # HTTPLocked:: 423 + # HTTPFailedDependency:: 424 + # HTTPUpgradeRequired:: 426 # HTTPPreconditionRequired:: 428 # HTTPTooManyRequests:: 429 # HTTPRequestHeaderFieldsTooLarge:: 431 @@ -357,6 +362,7 @@ module Net #:nodoc: # HTTPServiceUnavailable:: 503 # HTTPGatewayTimeOut:: 504 # HTTPVersionNotSupported:: 505 + # HTTPInsufficientStorage:: 507 # HTTPNetworkAuthenticationRequired:: 511 # # There is also the Net::HTTPBadResponse exception which is raised when diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 43494ca..fbaa947 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -30,6 +30,7 @@ end class Net::HTTPSwitchProtocol < Net::HTTPInformation # 101 HAS_BODY = false end +# 102 - RFC 2518; removed in RFC 4918 class Net::HTTPOK < Net::HTTPSuccess # 200 HAS_BODY = true @@ -52,10 +53,16 @@ end class Net::HTTPPartialContent < Net::HTTPSuccess # 206 HAS_BODY = true end +class Net::HTTPMultiStatus < Net::HTTPSuccess # 207 - RFC 4918 + HAS_BODY = true +end +# 208 Already Reported - RFC 5842; experimental +# 226 IM Used - RFC 3229; no famous implementation known -class Net::HTTPMultipleChoice < Net::HTTPRedirection # 300 +class Net::HTTPMultipleChoices < Net::HTTPRedirection # 300 HAS_BODY = true end +Net::HTTPMultipleChoice = Net::HTTPMultipleChoices class Net::HTTPMovedPermanently < Net::HTTPRedirection # 301 HAS_BODY = true end @@ -72,10 +79,11 @@ end class Net::HTTPUseProxy < Net::HTTPRedirection # 305 HAS_BODY = false end -# 306 unused +# 306 Switch Proxy - no longer unused class Net::HTTPTemporaryRedirect < Net::HTTPRedirection # 307 HAS_BODY = true end +# 308 Permanent Redirect - in draft class Net::HTTPBadRequest < Net::HTTPClientError # 400 HAS_BODY = true @@ -132,6 +140,21 @@ end class Net::HTTPExpectationFailed < Net::HTTPClientError # 417 HAS_BODY = true end +# 418 I'm a teapot - RFC 2324; a joke RFC +# 420 Enhance Your Calm - Twitter +class Net::HTTPUnprocessableEntity < Net::HTTPSuccess # 422 - RFC 4918 + HAS_BODY = true +end +class Net::HTTPLocked < Net::HTTPSuccess # 423 - RFC 4918 + HAS_BODY = true +end +class Net::HTTPFailedDependency < Net::HTTPSuccess # 424 - RFC 4918 + HAS_BODY = true +end +# 425 Unordered Collection - existed only in draft +class Net::HTTPUpgradeRequired < Net::HTTPSuccess # 426 - RFC 2817 + HAS_BODY = true +end class Net::HTTPPreconditionRequired < Net::HTTPClientError # 428 - RFC 6585 HAS_BODY = true end @@ -141,6 +164,10 @@ end class Net::HTTPRequestHeaderFieldsTooLarge < Net::HTTPClientError # 431 - RFC 6585 HAS_BODY = true end +# 444 No Response - Nginx +# 449 Retry With - Microsoft +# 450 Blocked by Windows Parental Controls - Microsoft +# 499 Client Closed Request - Nginx class Net::HTTPInternalServerError < Net::HTTPServerError # 500 HAS_BODY = true @@ -160,6 +187,13 @@ end class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505 HAS_BODY = true end +# 506 Variant Also Negotiates - RFC 2295; experimental +class Net::HTTPInsufficientStorage < Net::HTTPServerError # 507 - RFC 4918 + HAS_BODY = true +end +# 508 Loop Detected - RFC 5842; experimental +# 509 Bandwidth Limit Exceeded - Apache bw/limited extension +# 510 Not Extended - RFC 2774; experimental class Net::HTTPNetworkAuthenticationRequired < Net::HTTPServerError # 511 - RFC 6585 HAS_BODY = true end @@ -183,8 +217,9 @@ class Net::HTTPResponse '204' => Net::HTTPNoContent, '205' => Net::HTTPResetContent, '206' => Net::HTTPPartialContent, + '207' => Net::HTTPMultiStatus, - '300' => Net::HTTPMultipleChoice, + '300' => Net::HTTPMultipleChoices, '301' => Net::HTTPMovedPermanently, '302' => Net::HTTPFound, '303' => Net::HTTPSeeOther, @@ -210,6 +245,10 @@ class Net::HTTPResponse '415' => Net::HTTPUnsupportedMediaType, '416' => Net::HTTPRequestedRangeNotSatisfiable, '417' => Net::HTTPExpectationFailed, + '422' => Net::HTTPUnprocessableEntity, + '423' => Net::HTTPLocked, + '424' => Net::HTTPFailedDependency, + '426' => Net::HTTPUpgradeRequired, '428' => Net::HTTPPreconditionRequired, '429' => Net::HTTPTooManyRequests, '431' => Net::HTTPRequestHeaderFieldsTooLarge, @@ -220,6 +259,7 @@ class Net::HTTPResponse '503' => Net::HTTPServiceUnavailable, '504' => Net::HTTPGatewayTimeOut, '505' => Net::HTTPVersionNotSupported, + '507' => Net::HTTPInsufficientStorage, '511' => Net::HTTPNetworkAuthenticationRequired, } end diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb index 5d364e5..37a36fa 100644 --- a/lib/webrick/httpstatus.rb +++ b/lib/webrick/httpstatus.rb @@ -63,6 +63,7 @@ module WEBrick 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', + 207 => 'Multi-Status', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', @@ -88,6 +89,10 @@ module WEBrick 415 => 'Unsupported Media Type', 416 => 'Request Range Not Satisfiable', 417 => 'Expectation Failed', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', @@ -97,6 +102,7 @@ module WEBrick 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', + 507 => 'Insufficient Storage', 511 => 'Network Authentication Required', } -- 1.7.10.3