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

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-bug-203-open-net-http-sends-wrong-content-length/141602>\
**Category:** Development\
**Created:** [June 27, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/ruby-1-9-bug-203-open-net-http-sends-wrong-content-length/141602 "2008-06-27T15:32:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@anonymous](https://www.ruby-forum.com/u/anonymous)\
**Post date:** [June 27, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/ruby-1-9-bug-203-open-net-http-sends-wrong-content-length/141602/1 "2008-06-27T15:32:41Z")

</div>

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](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

```
