Ticket #80 (assigned defect)

Opened 2 months ago

Last modified 2 months ago

Connection#send_data should use String#bytesize if it's there

Reported by: lemon Assigned to: raggi (accepted)
Priority: minor Milestone:
Keywords: Cc:

Description

Connection#send_data currently uses String#length to figure out the size of the data chunk. This won't work on Ruby 1.9 since #length returns the character length of a string, not the byte length. When called with a string containing multibyte characters, EventMachine will only send part of the chunk. The same problem may be present in other parts of the EventMachine codebase.

A backwards-compatible fix would be to see if data responds to #bytesize and fall back to #length if it doesn't.

Change History

09/28/08 13:31:24 changed by raggi

  • owner set to raggi.
  • status changed from new to assigned.

This is an interesting problem. It turns out that size and bytesize may disagree, however, in most protocol implementations, one will have to index by char (in ruby), using slice. Need to write some more tests to be sure of what the state of play is.