[#32009] merging nokogiri to ext/ — Aaron Patterson <aaron@...>

I would like to merge nokogiri to ext for the 1.9.3 release. I spoke to

82 messages 2010/09/02
[#32010] Re: merging nokogiri to ext/ — "U.Nakamura" <usa@...> 2010/09/02

Hello,

[#32012] Re: merging nokogiri to ext/ — Ryan Davis <ryand-ruby@...> 2010/09/02

[#32030] Re: merging nokogiri to ext/ — "NARUSE, Yui" <naruse@...> 2010/09/03

Hi,

[#32033] Re: merging nokogiri to ext/ — "NARUSE, Yui" <naruse@...> 2010/09/03

2010/9/3 NARUSE, Yui <naruse@airemix.jp>:

[#32155] Re: merging nokogiri to ext/ — Yusuke ENDOH <mame@...> 2010/09/08

Currently, we're discussing three different topics:

[#32189] Re: merging nokogiri to ext/ — Aaron Patterson <aaron@...> 2010/09/09

On Thu, Sep 09, 2010 at 01:40:34AM +0900, Yusuke ENDOH wrote:

[#32056] [Ruby 1.8-Bug#3788][Open] URI cannot parse IPv6 addresses propertly — Adam Majer <redmine@...>

Bug #3788: URI cannot parse IPv6 addresses propertly

16 messages 2010/09/04

[#32110] Ruby 2.0 Wiki/Wish-list? — Joshua Ballanco <jballanc@...>

Hi all,

41 messages 2010/09/07
[#32114] Re: Ruby 2.0 Wiki/Wish-list? — "NARUSE, Yui" <naruse@...> 2010/09/08

2010/9/8 Joshua Ballanco <jballanc@gmail.com>:

[#32117] Re: Ruby 2.0 Wiki/Wish-list? — Joshua Ballanco <jballanc@...> 2010/09/08

On Sep 7, 2010, at 5:21 PM, NARUSE, Yui wrote:

[#32143] Re: Ruby 2.0 Wiki/Wish-list? — Roger Pack <rogerdpack2@...> 2010/09/08

> So, for example, a few things I've wanted for a long time:

[#32135] [Ruby-Bug#3802][Open] freeaddrinfo not found in WS2_32.dll — Thomas Volkmar Worm <redmine@...>

Bug #3802: freeaddrinfo not found in WS2_32.dll

16 messages 2010/09/08

[#32154] Making custom_lambda() work — Magnus Holm <judofyr@...>

A tiny suggestion for how we could make it possible to call lambdas

15 messages 2010/09/08
[#32159] Re: Making custom_lambda() work — Nikolai Weibull <now@...> 2010/09/08

On Wed, Sep 8, 2010 at 18:21, Magnus Holm <judofyr@gmail.com> wrote:

[#32156] Can we convert the standard library to gems? — James Edward Gray II <james@...>

Taken from the bundle Nokogiri thread:

98 messages 2010/09/08
[#32161] Re: Can we convert the standard library to gems? — Marcus Rueckert <darix@...> 2010/09/08

On 2010-09-09 01:45:43 +0900, James Edward Gray II wrote:

[#32166] Re: Can we convert the standard library to gems? — James Edward Gray II <james@...> 2010/09/08

On Sep 8, 2010, at 12:03 PM, Marcus Rueckert wrote:

[#32173] Re: Can we convert the standard library to gems? — Marcus Rueckert <darix@...> 2010/09/08

On 2010-09-09 02:54:26 +0900, James Edward Gray II wrote:

[#32249] Re: Can we convert the standard library to gems? — Aaron Patterson <aaron@...> 2010/09/09

On Thu, Sep 09, 2010 at 05:26:54AM +0900, Marcus Rueckert wrote:

[#32278] Re: Can we convert the standard library to gems? — Lucas Nussbaum <lucas@...> 2010/09/10

On 10/09/10 at 02:41 +0900, Aaron Patterson wrote:

[#32162] Re: Can we convert the standard library to gems? — Yusuke ENDOH <mame@...> 2010/09/08

Hi,

[#32216] Re: Can we convert the standard library to gems? — Ryan Davis <ryand-ruby@...> 2010/09/09

[#32229] Re: Can we convert the standard library to gems? — Yusuke ENDOH <mame@...> 2010/09/09

Hi,

[#32260] Re: Can we convert the standard library to gems? — Ryan Davis <ryand-ruby@...> 2010/09/09

[#32275] Re: Can we convert the standard library to gems? — Urabe Shyouhei <shyouhei@...> 2010/09/10

I'm off today so sorry if I missed some mails.

[#32293] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/10

Urabe,

[#32316] Re: Can we convert the standard library to gems? — Urabe Shyouhei <shyouhei@...> 2010/09/11

(2010/09/10 23:48), James Cox wrote:

[#32322] Re: Can we convert the standard library to gems? — James Tucker <jftucker@...> 2010/09/11

[#32335] Re: Can we convert the standard library to gems? — Urabe Shyouhei <shyouhei@...> 2010/09/12

I'm at an airport back to my home so in short,

[#32343] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/12

On Sun, Sep 12, 2010 at 6:51 AM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:

[#32382] Re: Can we convert the standard library to gems? — Urabe Shyouhei <shyouhei@...> 2010/09/14

(2010/09/13 3:54), James Cox wrote:

[#32383] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/14

On Tue, Sep 14, 2010 at 12:37 PM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:

[#32393] Re: Can we convert the standard library to gems? — Urabe Shyouhei <shyouhei@...> 2010/09/15

How difficult to make myself understood in English.

[#32396] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/15

On Wed, Sep 15, 2010 at 1:43 AM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:

[#32399] Re: Can we convert the standard library to gems? — Yusuke ENDOH <mame@...> 2010/09/15

Hi,

[#32400] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/15

On Wed, Sep 15, 2010 at 12:07 PM, Yusuke ENDOH <mame@tsg.ne.jp> wrote:

[#32401] Re: Can we convert the standard library to gems? — Marcus Rueckert <darix@...> 2010/09/15

On 2010-09-16 01:42:39 +0900, James Cox wrote:

[#32402] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/15

On Wed, Sep 15, 2010 at 1:35 PM, Marcus Rueckert <darix@opensu.se> wrote:

[#32411] Re: Can we convert the standard library to gems? — Marcus Rueckert <darix@...> 2010/09/15

On 2010-09-16 03:36:56 +0900, James Cox wrote:

[#32412] Re: Can we convert the standard library to gems? — James Cox <james@...> 2010/09/16

On Wednesday, September 15, 2010, Marcus Rueckert <darix@opensu.se> wrote:

[#32414] Re: Can we convert the standard library to gems? — Lucas Nussbaum <lucas@...> 2010/09/16

On 16/09/10 at 11:02 +0900, James Cox wrote:

[#32248] Replacing stdlib Date with C version — Jeremy Evans <code@...>

I've recently been working on a replacement for the stdlib Date class,

15 messages 2010/09/09

[#32290] [Ruby 1.9.2-Backport#3818][Open] Seg fault with ruby tmail and ruby 1.9.2 — Karl Baum <redmine@...>

Backport #3818: Seg fault with ruby tmail and ruby 1.9.2

10 messages 2010/09/10

[#32453] Why doesn’t Enumerable define a #last method? — Nikolai Weibull <now@...>

Hi!

9 messages 2010/09/17

[#32454] [Ruby 1.9-Feature#3845][Open] "in" infix operator — Yusuke Endoh <redmine@...>

Feature #3845: "in" infix operator

20 messages 2010/09/17
[#32489] Re: [Ruby 1.9-Feature#3845][Open] "in" infix operator — Benoit Daloze <eregontp@...> 2010/09/21

On 17 September 2010 12:30, Yusuke Endoh <redmine@ruby-lang.org> wrote:

[#32529] [Ruby 1.9-Bug#3869][Open] Logger#log does not handle or escape new-line characters. — Hal Brodigan <redmine@...>

Bug #3869: Logger#log does not handle or escape new-line characters.

9 messages 2010/09/23

[#32585] Proposal for Optional Static Typing for Ruby — Martin Pilkington <pilky@...>

Hi,

47 messages 2010/09/27
[#32588] Re: Proposal for Optional Static Typing for Ruby — Yukihiro Matsumoto <matz@...> 2010/09/27

Hi,

[#32592] Re: Proposal for Optional Static Typing for Ruby — Martin Pilkington <pilky@...> 2010/09/28

Hi Matz

[#32595] Re: Proposal for Optional Static Typing for Ruby — Asher <asher@...> 2010/09/28

Martin,

[#32611] Re: Proposal for Optional Static Typing for Ruby — Loren Segal <lsegal@...> 2010/09/28

Hi,

[#32628] Re: Proposal for Optional Static Typing for Ruby — Eleanor McHugh <eleanor@...> 2010/09/29

It strikes me that much of the premise behind this thread is misguided as it overlooks the importance of meta-programming in developing any Ruby program of substantive size. Where a Java or C++ programmer might write a factory method to create instances of a class and spend much of their effort enumerating types explicitly, it's not unusual in Ruby to write meta-programs which create a variety of class and method definitions on request to create or repurpose object instances for the task at hand.

[#32634] [Ruby 1.9-Bug#3889][Open] Incorrectly detected i686-w64-mingw32 as x64-mingw — Luis Lavena <redmine@...>

Bug #3889: Incorrectly detected i686-w64-mingw32 as x64-mingw

21 messages 2010/09/29

[ruby-core:32307] [Ruby 1.9-Feature#3622] Net::HTTP does not wait to send request body with Expect: 100-continue

From: Eric Hodel <redmine@...>
Date: 2010-09-10 20:26:57 UTC
List: ruby-core #32307
Issue #3622 has been updated by Eric Hodel.

File expect-continue.3.diff added

With your latest patch if you do not set the continue_timeout after the server is started it does not wait for "100 Continue".

h = Net::HTTP.new host, port
h.continue_timeout = 10 # does nothing

With your latest patch Net::HTTP does not send the HTTP header immediately, it waits for the continue timeout first.

Placing wait_for_continue after sending headers fixes this.

Does Net::HTTP require additional RDoc?  I think the current comments for the new methods are ok.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3622

----------------------------------------
http://redmine.ruby-lang.org

Attachments (1)

expect-continue.3.diff (6.28 KB, text/x-diff)
Index: lib/net/http.rb
===================================================================
--- lib/net/http.rb	(revision 29219)
+++ lib/net/http.rb	(working copy)
@@ -517,6 +517,7 @@ module Net   #:nodoc:
       @started = false
       @open_timeout = nil
       @read_timeout = 60
+      @continue_timeout = nil
       @debug_output = nil
       @use_ssl = false
       @ssl_context = nil
@@ -570,6 +571,16 @@ module Net   #:nodoc:
       @read_timeout = sec
     end
 
+    # Seconds to wait for 100 Continue response.  If the HTTP object does not
+    # receive a response in this many seconds it sends the request body.
+    attr_reader :continue_timeout
+
+    # Setter for the continue_timeout attribute.
+    def continue_timeout=(sec)
+      @socket.continue_timeout = sec if @socket
+      @continue_timeout = sec
+    end
+
     # returns true if the HTTP session is started.
     def started?
       @started
@@ -660,6 +671,7 @@ module Net   #:nodoc:
       end
       @socket = BufferedIO.new(s)
       @socket.read_timeout = @read_timeout
+      @socket.continue_timeout = @continue_timeout
       @socket.debug_output = @debug_output
       if use_ssl?
         if proxy?
@@ -1190,12 +1202,15 @@ module Net   #:nodoc:
 
     def transport_request(req)
       begin_transport req
-      req.exec @socket, @curr_http_version, edit_path(req.path)
-      begin
-        res = HTTPResponse.read_new(@socket)
-      end while res.kind_of?(HTTPContinue)
-      res.reading_body(@socket, req.response_body_permitted?) {
-        yield res if block_given?
+      res = catch(:response) {
+        req.exec @socket, @curr_http_version, edit_path(req.path)
+        begin
+          res = HTTPResponse.read_new(@socket)
+        end while res.kind_of?(HTTPContinue)
+        res.reading_body(@socket, req.response_body_permitted?) {
+          yield res if block_given?
+        }
+        res
       }
       end_transport req, res
       res
@@ -1740,6 +1755,7 @@ module Net   #:nodoc:
       delete 'Transfer-Encoding'
       supply_default_content_type
       write_header sock, ver, path
+      wait_for_continue sock, ver if sock.continue_timeout
       sock.write body
     end
 
@@ -1750,6 +1766,7 @@ module Net   #:nodoc:
       end
       supply_default_content_type
       write_header sock, ver, path
+      wait_for_continue sock, ver if sock.continue_timeout
       if chunked?
         while s = f.read(1024)
           sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
@@ -1768,6 +1785,22 @@ module Net   #:nodoc:
       set_content_type 'application/x-www-form-urlencoded'
     end
 
+    ##
+    # Waits up to the continue timeout for a response from the server provided
+    # we're speaking HTTP 1.1 and are expecting a 100-continue response.
+
+    def wait_for_continue(sock, ver)
+      if ver >= '1.1' and @header['expect'] and
+          @header['expect'].include?('100-continue') then
+        if IO.select [sock.io], nil, nil, sock.continue_timeout then
+          res = HTTPResponse.read_new sock
+          unless res.kind_of?(Net::HTTPContinue)
+            throw :response, res
+          end
+        end
+      end
+    end
+
     def write_header(sock, ver, path)
       buf = "#{@method} #{path} HTTP/#{ver}\r\n"
       each_capitalized do |k,v|
Index: lib/net/protocol.rb
===================================================================
--- lib/net/protocol.rb	(revision 29219)
+++ lib/net/protocol.rb	(working copy)
@@ -50,12 +50,14 @@ module Net # :nodoc:
     def initialize(io)
       @io = io
       @read_timeout = 60
+      @continue_timeout = nil
       @debug_output = nil
       @rbuf = ''
     end
 
     attr_reader :io
     attr_accessor :read_timeout
+    attr_accessor :continue_timeout
     attr_accessor :debug_output
 
     def inspect
Index: test/net/http/test_http.rb
===================================================================
--- test/net/http/test_http.rb	(revision 29219)
+++ test/net/http/test_http.rb	(working copy)
@@ -372,6 +372,87 @@ class TestNetHTTP_v1_2_chunked < Test::U
   end
 end
 
+class TestNetHTTPContinue < Test::Unit::TestCase
+  CONFIG = {
+    'host' => '127.0.0.1',
+    'port' => 10081,
+    'proxy_host' => nil,
+    'proxy_port' => nil,
+    'chunked' => true,
+  }
+
+  include TestNetHTTPUtils
+
+  def logfile
+    @debug = StringIO.new('')
+  end
+
+  def mount_proc(&block)
+    @server.mount('/continue', WEBrick::HTTPServlet::ProcHandler.new(block.to_proc))
+  end
+
+  def test_expect_continue
+    mount_proc {|req, res|
+      req.continue
+      res.body = req.query['body']
+    }
+    start {|http|
+      http.continue_timeout = 0.2
+      http.request_post('/continue', 'body=BODY', 'expect' => '100-continue') {|res|
+        assert_equal('BODY', res.read_body)
+      }
+    }
+    assert_match(/Expect: 100-continue/, @debug.string)
+    assert_match(/HTTP\/1.1 100 continue/, @debug.string)
+  end
+
+  def test_expect_continue_timeout
+    mount_proc {|req, res|
+      sleep 0.2
+      req.continue # just ignored because it's '100'
+      res.body = req.query['body']
+    }
+    start {|http|
+      http.continue_timeout = 0
+      http.request_post('/continue', 'body=BODY', 'expect' => '100-continue') {|res|
+        assert_equal('BODY', res.read_body)
+      }
+    }
+    assert_match(/Expect: 100-continue/, @debug.string)
+    assert_match(/HTTP\/1.1 100 continue/, @debug.string)
+  end
+
+  def test_expect_continue_error
+    mount_proc {|req, res|
+      res.status = 501
+      res.body = req.query['body']
+    }
+    start {|http|
+      http.continue_timeout = 0
+      http.request_post('/continue', 'body=ERROR', 'expect' => '100-continue') {|res|
+        assert_equal('ERROR', res.read_body)
+      }
+    }
+    assert_match(/Expect: 100-continue/, @debug.string)
+    assert_not_match(/HTTP\/1.1 100 continue/, @debug.string)
+  end
+
+  def test_expect_continue_error_while_waiting
+    mount_proc {|req, res|
+      res.status = 501
+      res.body = req.query['body']
+    }
+    start {|http|
+      http.continue_timeout = 0.5
+      http.request_post('/continue', 'body=ERROR', 'expect' => '100-continue') {|res|
+        assert_equal('ERROR', res.read_body)
+      }
+    }
+    assert_match(/Expect: 100-continue/, @debug.string)
+    assert_not_match(/HTTP\/1.1 100 continue/, @debug.string)
+  end
+end
+
 =begin
 class TestNetHTTP_proxy < Test::Unit::TestCase
   CONFIG = {

In This Thread