[ruby-cvs:73686] nobu:r66582 (trunk): Fix Net::Protocol::BufferedIO#write when sending large multi-byte string

nobu at ruby-lang.org nobu at ruby-lang.org
Thu Dec 27 13:49:12 JST 2018


nobu	2018-12-27 13:49:12 +0900 (Thu, 27 Dec 2018)

  New Revision: 66582

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66582

  Log:
    Fix Net::Protocol::BufferedIO#write when sending large multi-byte string
    
    This commit should fix Net::Protocol::BufferedIO#write when sending
    large multi-byte string like following example.
    
    ```
    $ ruby -rnet/http -rjson -v -e "Net::HTTP.post(URI('http://httpbin.org/post'), { text: '?\227?\129?\130'*100_000 }.to_json, 'Content-Type' => 'application/json')"
    ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
    Traceback (most recent call last):
            19: from -e:1:in `<main>'
            18: from lib/ruby/2.6.0/net/http.rb:500:in `post'
            17: from lib/ruby/2.6.0/net/http.rb:605:in `start'
            16: from lib/ruby/2.6.0/net/http.rb:920:in `start'
            15: from lib/ruby/2.6.0/net/http.rb:502:in `block in post'
            14: from lib/ruby/2.6.0/net/http.rb:1281:in `post'
            13: from lib/ruby/2.6.0/net/http.rb:1493:in `send_entity'
            12: from lib/ruby/2.6.0/net/http.rb:1479:in `request'
            11: from lib/ruby/2.6.0/net/http.rb:1506:in `transport_request'
            10: from lib/ruby/2.6.0/net/http.rb:1506:in `catch'
             9: from lib/ruby/2.6.0/net/http.rb:1507:in `block in transport_request'
             8: from lib/ruby/2.6.0/net/http/generic_request.rb:123:in `exec'
             7: from lib/ruby/2.6.0/net/http/generic_request.rb:189:in `send_request_with_body'
             6: from lib/ruby/2.6.0/net/protocol.rb:247:in `write'
             5: from lib/ruby/2.6.0/net/protocol.rb:265:in `writing'
             4: from lib/ruby/2.6.0/net/protocol.rb:248:in `block in write'
             3: from lib/ruby/2.6.0/net/protocol.rb:275:in `write0'
             2: from lib/ruby/2.6.0/net/protocol.rb:275:in `each_with_index'
             1: from lib/ruby/2.6.0/net/protocol.rb:275:in `each'
    lib/ruby/2.6.0/net/protocol.rb:280:in `block in write0': undefined method `bytesize' for nil:NilClass (NoMethodError)
    ```
    
    [Fix GH-2058]
    
    From: Eito Katagiri <eitoball at gmail.com>

  Modified files:
    trunk/lib/net/protocol.rb
    trunk/test/net/protocol/test_protocol.rb


More information about the ruby-cvs mailing list