From 0d7a94e31d3d0209c0dc520d55ff946f3e8c8bfc Mon Sep 17 00:00:00 2001 From: drbrain Date: Fri, 8 Jun 2012 22:40:14 +0000 Subject: * lib/net/http/responses.rb: Add RFC 6586 response codes. Patch by Sangil Jung. [ruby-trunk - Feature #6480] * lib/net/http/response.rb: ditto * lib/net/http.rb: ditto * lib/webrick/httpstatus.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/net/http.rb | 4 ++++ lib/net/http/response.rb | 4 ++++ lib/net/http/responses.rb | 31 ++++++++++++++++++++++++------- lib/webrick/httpstatus.rb | 6 +++++- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c18c47575..32dfa5e332 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Jun 9 07:39:50 2012 Eric Hodel + + * lib/net/http/responses.rb: Add RFC 6586 response codes. Patch by + Sangil Jung. [ruby-trunk - Feature #6480] + * lib/net/http/response.rb: ditto + * lib/net/http.rb: ditto + * lib/webrick/httpstatus.rb: ditto + Sat Jun 9 01:24:28 2012 Tanaka Akira * process.c (rb_exec_err): before_exec() call moved from proc_exec_cmd diff --git a/lib/net/http.rb b/lib/net/http.rb index 40a479cd4d..a2a1b935bd 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -347,6 +347,9 @@ module Net #:nodoc: # HTTPUnsupportedMediaType:: 415 # HTTPRequestedRangeNotSatisfiable:: 416 # HTTPExpectationFailed:: 417 + # HTTPPreconditionRequired:: 428 + # HTTPTooManyRequests:: 429 + # HTTPRequestHeaderFieldsTooLarge:: 431 # HTTPServerError:: 5xx # HTTPInternalServerError:: 500 # HTTPNotImplemented:: 501 @@ -354,6 +357,7 @@ module Net #:nodoc: # HTTPServiceUnavailable:: 503 # HTTPGatewayTimeOut:: 504 # HTTPVersionNotSupported:: 505 + # HTTPNetworkAuthenticationRequired:: 511 # # There is also the Net::HTTPBadResponse exception which is raised when # there is a protocol error. diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 9d37d08a6d..a5c30a87d6 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -55,6 +55,9 @@ # 415 HTTPUnsupportedMediaType # 416 HTTPRequestedRangeNotSatisfiable # 417 HTTPExpectationFailed +# 428 HTTPPreconditionRequired +# 429 HTTPTooManyRequests +# 431 HTTPRequestHeaderFieldsTooLarge # # 5xx HTTPServerError # 500 HTTPInternalServerError @@ -63,6 +66,7 @@ # 503 HTTPServiceUnavailable # 504 HTTPGatewayTimeOut # 505 HTTPVersionNotSupported +# 511 HTTPNetworkAuthenticationRequired # # xxx HTTPUnknownResponse # diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb index 659b88c32b..d17a452e7f 100644 --- a/lib/net/http/responses.rb +++ b/lib/net/http/responses.rb @@ -116,6 +116,16 @@ end class Net::HTTPPreconditionFailed < Net::HTTPClientError # 412 HAS_BODY = true end +class Net::HTTPPreconditionRequired < Net::HTTPClientError # 428 + HAS_BODY = true +end +class Net::HTTPTooManyRequests < Net::HTTPClientError # 429 + HAS_BODY = true +end +class Net::HTTPRequestHeaderFieldsTooLarge < Net::HTTPClientError # 431 + HAS_BODY = true +end + class Net::HTTPRequestEntityTooLarge < Net::HTTPClientError # 413 HAS_BODY = true end @@ -133,22 +143,25 @@ class Net::HTTPExpectationFailed < Net::HTTPClientError # 417 HAS_BODY = true end -class Net::HTTPInternalServerError < Net::HTTPServerError # 500 +class Net::HTTPInternalServerError < Net::HTTPServerError # 500 + HAS_BODY = true +end +class Net::HTTPNotImplemented < Net::HTTPServerError # 501 HAS_BODY = true end -class Net::HTTPNotImplemented < Net::HTTPServerError # 501 +class Net::HTTPBadGateway < Net::HTTPServerError # 502 HAS_BODY = true end -class Net::HTTPBadGateway < Net::HTTPServerError # 502 +class Net::HTTPServiceUnavailable < Net::HTTPServerError # 503 HAS_BODY = true end -class Net::HTTPServiceUnavailable < Net::HTTPServerError # 503 +class Net::HTTPGatewayTimeOut < Net::HTTPServerError # 504 HAS_BODY = true end -class Net::HTTPGatewayTimeOut < Net::HTTPServerError # 504 +class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505 HAS_BODY = true end -class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505 +class Net::HTTPNetworkAuthenticationRequired < Net::HTTPServerError # 511 HAS_BODY = true end @@ -198,13 +211,17 @@ class Net::HTTPResponse '415' => Net::HTTPUnsupportedMediaType, '416' => Net::HTTPRequestedRangeNotSatisfiable, '417' => Net::HTTPExpectationFailed, + '428' => Net::HTTPPreconditionRequired, + '429' => Net::HTTPTooManyRequests, + '431' => Net::HTTPRequestHeaderFieldsTooLarge, '500' => Net::HTTPInternalServerError, '501' => Net::HTTPNotImplemented, '502' => Net::HTTPBadGateway, '503' => Net::HTTPServiceUnavailable, '504' => Net::HTTPGatewayTimeOut, - '505' => Net::HTTPVersionNotSupported + '505' => Net::HTTPVersionNotSupported, + '511' => Net::HTTPNetworkAuthenticationRequired, } end diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb index 9eee38a40f..5d364e598a 100644 --- a/lib/webrick/httpstatus.rb +++ b/lib/webrick/httpstatus.rb @@ -88,12 +88,16 @@ module WEBrick 415 => 'Unsupported Media Type', 416 => 'Request Range Not Satisfiable', 417 => 'Expectation Failed', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported' + 505 => 'HTTP Version Not Supported', + 511 => 'Network Authentication Required', } # Maps a status code to the corresponding Status class -- cgit v1.2.3