Project

General

Profile

Feature #14688

Net::HTTPResponse#value raises "Net::HTTPServerException" in 4xx response

Added by unasuke (Yusuke Nakamura) 6 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:86545]

Description

Call value method to an instance of Net::HTTPResponse it raises Net::HTTPServerException in case of HTTP response status code is 4xx.

But HTTP response status code 4xx means "Client error response" not "Server response" so I think that's wrong naming.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#Client_error_responses

Therefore, I think it's maybe specifications bug, but it cause breaking changes in many ruby programs to change exception name.

I propose to create Net::HTTPClientException as alias of the Net::HTTPServerException for compatibility.

lib_net_http_exceptions.patch (999 Bytes) lib_net_http_exceptions.patch unasuke (Yusuke Nakamura), 04/15/2018 01:35 PM
lib_net_http_exceptions_with_deprecate.patch (1.08 KB) lib_net_http_exceptions_with_deprecate.patch unasuke (Yusuke Nakamura), 05/10/2018 03:57 PM

Associated revisions

Revision 8e37f176
Added by naruse (Yui NARUSE) 5 months ago

Add Net::HTTPClientException [Bug #14688]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63590
Added by naruse (Yui NARUSE) 5 months ago

Add Net::HTTPClientException [Bug #14688]

Revision 439e5078
Added by naruse (Yui NARUSE) 5 months ago

Use Net::HTTPClientException instead of Net::HTTPServerException

Net::HTTPServerException has been deprecated since r63590. [Bug #14688]
And net/http/responses.rb uses the deprecated constant, so Ruby warns of the deprecation.

Example:

$ ruby -r net/http -e ''
/home/pocke/.rbenv/versions/trunk/lib/ruby/2.6.0/net/http/responses.rb:22: warning: constant Net::HTTPServerException is deprecated

This change suppresses the warning.
From: Masataka Pocke Kuwabara kuwabara@pocke.me

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63591
Added by naruse (Yui NARUSE) 5 months ago

Use Net::HTTPClientException instead of Net::HTTPServerException

Net::HTTPServerException has been deprecated since r63590. [Bug #14688]
And net/http/responses.rb uses the deprecated constant, so Ruby warns of the deprecation.

Example:

$ ruby -r net/http -e ''
/home/pocke/.rbenv/versions/trunk/lib/ruby/2.6.0/net/http/responses.rb:22: warning: constant Net::HTTPServerException is deprecated

This change suppresses the warning.
From: Masataka Pocke Kuwabara kuwabara@pocke.me

History

#1 [ruby-core:86549] Updated by k0kubun (Takashi Kokubun) 6 months ago

I like this. If nobody has an objection, I want to deprecate_constant the old one, and would like the same fix for Net::ProtoServerError as well.

#2 [ruby-core:86557] Updated by shevegen (Robert A. Heiler) 6 months ago

The described transition path makes sense (to me).

#3 [ruby-core:86608] Updated by usa (Usaku NAKAMURA) 6 months ago

  • Assignee set to naruse (Yui NARUSE)
  • Status changed from Open to Assigned

At DevelopersMeeting20180419Japan, adding the alias is accepted.

#4 [ruby-core:86970] Updated by unasuke (Yusuke Nakamura) 5 months ago

k0kubun (Takashi Kokubun) wrote:

I like this. If nobody has an objection, I want to deprecate_constant the old one, and would like the same fix for Net::ProtoServerError as well.

I updated the patch. Like this?

#5 Updated by naruse (Yui NARUSE) 5 months ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r63590.


Add Net::HTTPClientException [Bug #14688]

#6 Updated by naruse (Yui NARUSE) 5 months ago

  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
  • ruby -v deleted (2.6.0dev)
  • Tracker changed from Bug to Feature

#7 [ruby-core:87488] Updated by usa (Usaku NAKAMURA) 4 months ago

I suspect that deprecating Net::ProtoServerError is wrong.
The exception seems to be "something error reported from server", and is derived not only by Net::HTTPServerException but also Net::SMTPServerBusy.

Also available in: Atom PDF