lib/io_streams/paths/http.rb in iostreams-1.0.0.beta7 vs lib/io_streams/paths/http.rb in iostreams-1.0.0
- old
+ new
@@ -45,21 +45,23 @@
def to_s
url
end
+ private
+
# Read a file using an http get.
#
# For example:
# IOStreams.path('https://www5.fdic.gov/idasp/Offices2.zip').reader {|file| puts file.read}
#
# Read the file without unzipping and streaming the first file in the zip:
# IOStreams.path('https://www5.fdic.gov/idasp/Offices2.zip').stream(:none).reader {|file| puts file.read}
#
# Notes:
# * Since Net::HTTP download only supports a push stream, the data is streamed into a tempfile first.
- def reader(&block)
+ def stream_reader(&block)
handle_redirects(url, http_redirect_count, &block)
end
def handle_redirects(uri, http_redirect_count, &block)
uri = URI.parse(uri) unless uri.is_a?(URI)
@@ -89,10 +91,10 @@
# Since Net::HTTP download only supports a push stream, write it to a tempfile first.
Utils.temp_file_name('iostreams_http') do |file_name|
::File.open(file_name, 'wb') { |io| response.read_body { |chunk| io.write(chunk) } }
# Return a read stream
- result = ::File.open(file_name, "rb") { |io| streams.reader(io, &block) }
+ result = ::File.open(file_name, "rb") { |io| builder.reader(io, &block) }
end
end
end
result
end