https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-05-30T07:15:32ZRuby Issue Tracking SystemRuby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=722982018-05-30T07:15:32Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I think it would make sense, given how important http status codes<br>
are in general (and people who use net/http may also usually deal<br>
with http status codes).</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=723022018-05-30T11:33:15Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:shevegen@gmail.com" class="email">shevegen@gmail.com</a> wrote:</p>
<blockquote>
<p>I think it would make sense, given how important http status codes<br>
are in general (and people who use net/http may also usually deal<br>
with http status codes).</p>
</blockquote>
<p>I disagree, nothing in net/http client code relies on status<br>
code messages. Loading status messages would needlessly<br>
increase the memory footprint of people who only want an<br>
HTTP client.</p>
<p>Having a code number -> message mapping is useful to servers<br>
(but unfortunately having <code>require "net/http"</code> in<br>
net/http/status would needlessly bloat servers, too).</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=723242018-06-01T03:14:59Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>net/http itself doesn't need net/http/status.<br>
Therefore at this time it's intentional.<br>
Though I may change it if there's a reasonable use case to require it.</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=723252018-06-01T04:57:51Ztonytonyjan (Weihang Jian)tonytonyjan@gmail.com
<ul></ul><p>IMHO, I would suggest use <code>Kernel::autoload</code>, thus we don't need to type <code>net/http/status</code> when we want it, and they will never be loaded into memory until we try to access the constant <code>STATUS_CODES</code>. Isn't it win-win?</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=723262018-06-01T05:11:01Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>tonytonyjan (Wei-Hang Jian) wrote:</p>
<blockquote>
<p>IMHO, I would suggest use <code>Kernel::autoload</code>, thus we don't need to type <code>net/http/status</code> when we want it, and they will never be loaded into memory until we try to access the constant <code>STATUS_CODES</code>. Isn't it win-win?</p>
</blockquote>
<p>No, it's a trade-off, and a bad trade-off in my opinion. See <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: "I strongly discourage the use of autoload in any standard libraries" (Re: autoload will be dead) (Closed)" href="https://bugs.ruby-lang.org/issues/5653">#5653</a>. Even if the particular implementation issues with autoload are or have been addressed, my main problem with autoload is that libraries that use it are a pain to use in security sensitive code that uses Dir.chroot. Well designed libraries should require all files at load/application startup time, and avoid requiring files during application runtime, and autoload is a hidden runtime require.</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=723302018-06-01T06:26:01Ztonytonyjan (Weihang Jian)tonytonyjan@gmail.com
<ul></ul><p>jeremyevans0 (Jeremy Evans) wrote:</p>
<blockquote>
<p>tonytonyjan (Wei-Hang Jian) wrote:</p>
<blockquote>
<p>IMHO, I would suggest use <code>Kernel::autoload</code>, thus we don't need to type <code>net/http/status</code> when we want it, and they will never be loaded into memory until we try to access the constant <code>STATUS_CODES</code>. Isn't it win-win?</p>
</blockquote>
<p>No, it's a trade-off, and a bad trade-off in my opinion. See <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: "I strongly discourage the use of autoload in any standard libraries" (Re: autoload will be dead) (Closed)" href="https://bugs.ruby-lang.org/issues/5653">#5653</a>. Even if the particular implementation issues with autoload are or have been addressed, my main problem with autoload is that libraries that use it are a pain to use in security sensitive code that uses Dir.chroot. Well designed libraries should require all files at load/application startup time, and avoid requiring files during application runtime, and autoload is a hidden runtime require.</p>
</blockquote>
<p>Hi Jeremy, thank you for the reference, I didn't know that thread before (It seems like there has not been a conclusion yet :(</p>
<p>By the way, I can see that <code>cgi.rb</code> (<a href="https://bugs.ruby-lang.org/projects/ruby-trunk/repository/entry/lib/cgi.rb#L296" class="external">https://bugs.ruby-lang.org/projects/ruby-trunk/repository/entry/lib/cgi.rb#L296</a>) is still using <code>autoload</code> so I am not quite sure if <code>autoload</code> is really deprecated for stdlib currently.</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=725782018-06-21T12:43:14Zsakuro (Sakuro OZAWA)
<ul></ul><p>naruse (Yui NARUSE) wrote:</p>
<blockquote>
<p>net/http itself doesn't need net/http/status.</p>
</blockquote>
<p>Agreed. I'm OK to close this issue.</p> Ruby master - Bug #14795: Should 'net/http' require 'net/http/status' ?https://bugs.ruby-lang.org/issues/14795?journal_id=787422019-06-20T17:30:32Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>