diff --git a/lib/em-websocket/framing07.rb b/lib/em-websocket/framing07.rb index 58318e4..d744812 100644 --- a/lib/em-websocket/framing07.rb +++ b/lib/em-websocket/framing07.rb @@ -3,13 +3,13 @@ module EventMachine module WebSocket module Framing07 - + def initialize_framing @data = MaskedString.new @application_data_buffer = '' # Used for MORE frames @frame_type = nil end - + def process_data error = false @@ -35,7 +35,7 @@ def process_data error = true next end - + # Only using the last 4 bytes for now, till I work out how to # unpack 8 bytes. I'm sure 4GB frames will do for now :) l = @data.getbytes(pointer+4, 4).unpack('N').first @@ -48,7 +48,7 @@ def process_data error = true next end - + l = @data.getbytes(pointer, 2).unpack('n').first pointer += 2 l @@ -81,7 +81,7 @@ def process_data application_data = @data.getbytes(pointer, payload_length) pointer += payload_length @data.unset_mask if mask - + # Throw away data up to pointer @data.slice!(0...pointer) @@ -120,7 +120,7 @@ def process_data end end # end while end - + def send_frame(frame_type, application_data) debug [:sending_frame, frame_type, application_data] @@ -128,7 +128,7 @@ def send_frame(frame_type, application_data) raise WebSocketError, "Cannot send data frame since connection is closing" end - frame = '' + frame = String.new opcode = type_to_opcode(frame_type) byte1 = opcode | 0b10000000 # fin bit set, rsv1-3 are 0 diff --git a/lib/em-websocket/masking04.rb b/lib/em-websocket/masking04.rb index ad050e9..27104a5 100644 --- a/lib/em-websocket/masking04.rb +++ b/lib/em-websocket/masking04.rb @@ -25,7 +25,7 @@ def getbyte(index) end def getbytes(start_index, count) - data = '' + data = String.new data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) count.times do |i| data << getbyte(start_index + i)