Project

General

Profile

Actions

Feature #9527

open

make Net::HTTP.get_print not only to $stdout but to an IO as a parameter

Added by bdimych (Dmitry Bolshakov) almost 11 years ago. Updated almost 11 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:60824]

Description

e.g.

url = 'http://server/path/large-file.zip'
fh = File.new(File.basename(url), 'wb')
Net::HTTP.get_print(URI(url), fh)
fh.close

imho looks good

Updated by srawlins (Sam Rawlins) almost 11 years ago

I opened up an alternative to this request in #9556.

I really like your suggestion. It is very strange that HTTP.get_print only prints to $stdout. However, the method signature of HTTP.get_print,

HTTP.get_print(uri_or_host, path = nil, port = nil)

makes it very awkward to add an optional IO handle. I think my vote would actually be to remove HTTP.get_print. It does not feel like it belongs in the standard library (and hasn't been updated since 2005), and the 5 lines of code could even just be moved into the RDoc for HTTP.get or a similar method.

Actions

Also available in: Atom PDF

Like0
Like0