[ruby-core:78158] [Ruby trunk Misc#12935] Webrick: Update HTTP Status codes, share them
From:
cardoso_tiago@...
Date:
2016-11-15 21:21:32 UTC
List:
ruby-core #78158
Issue #12935 has been updated by Tiago Cardoso.
Thoroughness aside, what would be the best approach? Having it in a gem is the easiest way, but it's an extra dependency to resolve (unless it's bundled with ruby, like openssl or net-telnet). I'd aim at availability, as this is a common set of vars shared both by http server and clients (and cgi?), and can be reused by other third-party servers like thin or puma.
----------------------------------------
Misc #12935: Webrick: Update HTTP Status codes, share them
https://bugs.ruby-lang.org/issues/12935#change-61515
* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I was looking for a common source of http status-to-reason map in ruby, and I've found many sources that address the same, some of them overlapping, most of them clearly copy-pasting from each other. In the process, I also found that the current hashmap used by webrick seems not to be up-to-date. Compare:
https://github.com/nahi/ruby/blob/webrick_trunk/lib/webrick/httpstatus.rb#L56-L97
with https://github.com/puma/puma/blob/3f66b3d7d4413f843e4e541c4d282238318c4cd2/lib/puma/const.rb#L16-L74
I started (this thread in puma)[https://github.com/puma/puma/issues/1133] to see about openness is centralizing this information in ruby (or just use an updated version of webrick hash), and I found out some interesting things, like the fact that rails reloading is not compatible with some of these things.
My main motivation would be to have something similar to nodejs's `http.STATUS_CODES`:
~~~
> require("http").STATUS_CODES
{ '100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'200': 'OK',
....
~~~
As http is something which is internally implemented in ruby's stdlib, question would just remain on how and where to implement it, and public API stability and "up-to-date"ness guarantees. I'd suggest maybe making it part of "net/http", like:
~~~ruby
require "net/http/status"
puts Net::HTTP::STATUS_CODES
~~~
but that's just a suggestion.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>