Project

General

Profile

Actions

Feature #5461

open

Add pipelining to Net::HTTP

Added by drbrain (Eric Hodel) about 13 years ago. Updated almost 7 years ago.

Status:
Assigned
Target version:
-
[ruby-core:40217]

Description

=begin
The attached patch adds HTTP/1.1 pipelining support to Net::HTTP.

Pipelining is only performed on HTTP/1.1 servers. Net::HTTP will check if the server supports pipelining by using the first request in the list. The user can override this via setting (({http.pipelining = true})).

If a server does not support pipelining or there is an error during pipelining an error will be raised that contains the requests that not have been delivered yet and the responses that have been received.

The patch includes documentation explaining the fine details.

Example:

requests = []
requests << Net::HTTP::Get.new('/images/bug.png')
requests << Net::HTTP::Get.new('/images/date.png')
requests << Net::HTTP::Get.new('/images/find.png')

http = Net::HTTP.new 'localhost'
http.start do
http.pipeline requests do |req, res|
open File.basename(req.path), 'wb' do |io|
io.write res.body
end
end
end

Implementation notes:

  • The current Net::HTTP tests make it very difficult to test bad behavior by servers. In test/net/http/utils.rb I introduced a method to replace Net::BufferedIO with a subclass that can behave incorrectly.
  • Net::HTTP#pipeline does not fall back to sending requests one-by-one for HTTP/1.1 servers. I think this is acceptable as the user can use existing Net::HTTP code to send requests one-by-one.

=end


Files

net.http.rb.pipeline.patch (26.2 KB) net.http.rb.pipeline.patch drbrain (Eric Hodel), 10/19/2011 07:37 AM

Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #5064: HTTP user-agent classAssignedmatz (Yukihiro Matsumoto)Actions

Updated by mame (Yusuke Endoh) over 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)

I tentatively assign this issue to Naruse-san because
he is running for the maintainer of net/http.

--
Yusuke Endoh

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Target version changed from 2.0.0 to 2.6
Actions #3

Updated by naruse (Yui NARUSE) almost 7 years ago

  • Target version deleted (2.6)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0