[Ruby 1.9 - Bug #203] (Open) net/http sends wrong content-length

e$B%A%1%C%He(B #203 e$B$,Js9p$5$l$^$7$?!#e(B (by Anonymous)


Bug #203: net/http sends wrong content-length
http://redmine.ruby-lang.org/issues/show/203

e$B5/I<<Te(B: Anonymous
e$B%9%F!<%?%9e(B: Open
e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B:
e$B%+%F%4%je(B:
Target version:

String#size returns count of chars, not count of bytes.

It is necessary to use bytesize method.

Index: lib/net/http.rb

— lib/net/http.rb (revision 17614)
+++ lib/net/http.rb (working copy)
@@ -1643,7 +1643,7 @@
private

  def send_request_with_body(sock, ver, path, body)
  •  self.content_length = body.length
    
  •  self.content_length = body.bytesize
     delete 'Transfer-Encoding'
     supply_default_content_type
     write_header sock, ver, path