From: mudge@... Date: 2018-07-04T20:43:49+00:00 Subject: [ruby-core:87789] [Ruby trunk Feature#14896] Expose Net::HTTPResponse socket for integration with libraries expecting an IO Issue #14896 has been reported by mudge (Paul Mucur). ---------------------------------------- Feature #14896: Expose Net::HTTPResponse socket for integration with libraries expecting an IO https://bugs.ruby-lang.org/issues/14896 * 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: