Project

General

Profile

Actions

Feature #9556

open

Add HTTP#get block functionality to HTTP.get

Added by srawlins (Sam Rawlins) about 10 years ago.

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

Description

This is kind of an alternative to #9527.

HTTP#get can be passed a block. The shortcut method, HTTP.get, however, cannot. This patch adds such functionality.

This allows someone to be able to write the response of a GET, in fragments, without dealing directly with Net::HTTPResponse, like the request in #9527:

File.open('result.zip', 'wb') {|f|
  Net::HTTP.get('www.example.com', '/file.zip') do |chunk|
    f.write chunk
  end
}

This patch includes that example as documentation, and a test. It is attached, and available at: https://github.com/srawlins/ruby/compare/add-block-to-http-get


Files

add-block-to-http-get.patch (2.03 KB) add-block-to-http-get.patch srawlins (Sam Rawlins), 02/23/2014 05:52 AM

No data to display

Actions

Also available in: Atom PDF

Like0