From: "hsbt (Hiroshi SHIBATA)" Date: 2021-11-30T11:46:33+00:00 Subject: [ruby-core:106340] [Ruby master Feature#5778] Allow WEBrick::HTTPResponse to send IO-duck-typed bodies Issue #5778 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Assigned to Closed webrick is removed from ruby repo since Ruby 3.0. The canonical repo is here: https://github.com/ruby/webrick/ ---------------------------------------- Feature #5778: Allow WEBrick::HTTPResponse to send IO-duck-typed bodies https://bugs.ruby-lang.org/issues/5778#change-94977 * Author: regularfry (Alex Young) * Status: Closed * Priority: Normal * Assignee: normalperson (Eric Wong) ---------------------------------------- WEBrick::HTTPResponse currently type-checks for IO to determine how to transfer content to the outgoing socket. Because of this, it's not possible to use "IO-like" objects as data sources unless they specifically inherit from IO. The interface HTTPResponse requires from its body objects is very simple: it only calls #read and #close, and optionally #bytesize. This means that the type-check is needlessly strict, and prevents custom objects from being used as data sources. The attached patch removes the type-check on IO, allowing duck-typed objects to be used. The downside to this patch is that you can't pass in objects that duck-type to String's interface. It wouldn't be hard to remove that restriction if necessary, but I figured this was the less intrusive approach. ---Files-------------------------------- httpresponse.patch (2.76 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: