From: shevegen@... Date: 2018-07-04T22:05:29+00:00 Subject: [ruby-core:87790] [Ruby trunk Feature#14896] Expose Net::HTTPResponse socket for integration with libraries expecting an IO Issue #14896 has been updated by shevegen (Robert A. Heiler). I have nothing useful to add to the issue at hand as I only very rarely use Net:: directly (my use cases usually start and end with open-uri which I think is great) - the reason I comment here is to suggest to you to add your feature request to the next developer meeting that is bound to happen in two weeks: https://bugs.ruby-lang.org/issues/14861 The discussions there often help get things moving, either because of direct approval by matz, or by requestung some feedback or making modifications/suggestions to the issue at hand. The use case was mentioned as well ("streaming a .tar.gz file"; I guess it applies to all compressed files like .zip or .tar.xz and so forth). If I may suggest, the documentation could mention the use case and/or provide examples to it and clarifications. For example, reading "meaningful body" leads me to wonder in what context the body is meant here (I assume to the method itself) and what is meaningful and what is not or what is meant with it. ---------------------------------------- Feature #14896: Expose Net::HTTPResponse socket for integration with libraries expecting an IO https://bugs.ruby-lang.org/issues/14896#change-72807 * Author: mudge (Paul Mucur) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- As several stdlib libraries support reading from IO-compatible objects (e.g. Zlib::GzipReader, Gem::Package::TarReader), would you be open to making the socket of a Net::HTTPResponse public? This would enable such use cases as streaming a .tar.gz file with the following code: ~~~ uri = URI('http://www.example.com/huge.tar.gz') Net::HTTP.start(uri.host, uri.port) do |http| http.request_get(uri) do |response| Zlib::GzipReader.wrap(response.socket) do |gz| Gem::Package::TarReader.new(gz) do |tar| tar.each do |entry| yield entry.read end end end end end ~~~ We could document this with the same caveat as when passing a block for streaming bodies: noting that the response will not contain a "(meaningful) body" if the user does anything with the underlying socket. ---Files-------------------------------- response-socket.patch (617 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: