summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-13 15:20:27 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-13 15:20:27 +0000
commit3703619ed970c5ebcf2ec7b2d8a848fa5550dcea (patch)
treec8258e07f3627ec1bc9efdb17da2b22b12a90fee
parenta29bdaf63f941f760d6a2e4a42b1b6789e861550 (diff)
downloadruby-3703619ed970c5ebcf2ec7b2d8a848fa5550dcea.tar.gz
* lib/net/http/responses.rb, lib/webrick/httpstatus.rb: Add HTTP
response codes added in RFCs 2817 and 4918. [ruby-core:45547] [Feature #6569] * lib/net/http/responses.rb: Rename Net::HTTPMultipleChoice to Net::HTTPMultipleChoices, leaving the former as alias to the latter for backward compatibitily. [ruby-core:45547] [Feature #6569] * lib/net/http/responses.rb: Add comments about unused, still-in-draft and private extension response codes. [ruby-core:45547] [Feature #6569] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog15
-rw-r--r--lib/net/http.rb8
-rw-r--r--lib/net/http/responses.rb46
-rw-r--r--lib/webrick/httpstatus.rb6
4 files changed, 71 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9314f30410..1b9cfe558f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Thu Jun 14 00:16:59 2012 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/net/http/responses.rb, lib/webrick/httpstatus.rb: Add HTTP
+ response codes added in RFCs 2817 and 4918. [ruby-core:45547]
+ [Feature #6569]
+
+ * lib/net/http/responses.rb: Rename Net::HTTPMultipleChoice to
+ Net::HTTPMultipleChoices, leaving the former as alias to the
+ latter for backward compatibitily. [ruby-core:45547]
+ [Feature #6569]
+
+ * lib/net/http/responses.rb: Add comments about unused,
+ still-in-draft and private extension response codes.
+ [ruby-core:45547] [Feature #6569]
+
Wed Jun 13 22:44:32 2012 Naohisa Goto <ngotogenome@gmail.com>
* test/dl/test_func.rb (test_qsort1, test_qsort2): use TYPE_SIZE_T
diff --git a/lib/net/http.rb b/lib/net/http.rb
index a2a1b935bd..9521f6c20a 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 43494caaf1..fbaa947f65 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 5d364e598a..37a36faa94 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',
}