Class: TestLineAndTextProtocol::LineAndTextTest

Inherits:
EventMachine::Protocols::LineAndTextProtocol show all
Defined in:
lib/ext/eventmachine-0.12.10/tests/test_ltp.rb

Overview


Constant Summary

Constants inherited from EventMachine::Protocols::LineAndTextProtocol

EventMachine::Protocols::LineAndTextProtocol::MaxBinaryLength, EventMachine::Protocols::LineAndTextProtocol::MaxLineLength

Instance Attribute Summary

Attributes inherited from EventMachine::Connection

#signature

Instance Method Summary collapse

Methods inherited from EventMachine::Protocols::LineAndTextProtocol

#initialize, #receive_data, #set_binary_mode, #unbind

Methods inherited from EventMachine::Connection

#associate_callback_target, #close_connection, #close_connection_after_writing, #comm_inactivity_timeout, #comm_inactivity_timeout=, #connection_completed, #detach, #error?, #get_outbound_data_size, #get_peer_cert, #get_peername, #get_pid, #get_sock_opt, #get_sockname, #get_status, #initialize, new, #notify_readable=, #notify_readable?, #notify_writable=, #notify_writable?, #pause, #paused?, #pending_connect_timeout, #pending_connect_timeout=, #proxy_incoming_to, #proxy_target_unbound, #receive_data, #reconnect, #resume, #send_data, #send_datagram, #send_file_data, #set_comm_inactivity_timeout, #set_pending_connect_timeout, #ssl_handshake_completed, #ssl_verify_peer, #start_tls, #stop_proxying, #stream_file_data, #unbind

Constructor Details

This class inherits a constructor from EventMachine::Protocols::LineAndTextProtocol

Instance Method Details

#post_initObject



106
107
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp.rb', line 106

def post_init
end

#receive_binary_data(text) ⇒ Object



115
116
117
118
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp.rb', line 115

def receive_binary_data text
  send_data "received #{text.length} bytes"
  close_connection_after_writing
end

#receive_line(line) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp.rb', line 108

def receive_line line
  if line =~ /content-length:\s*(\d+)/i
    @content_length = $1.to_i
  elsif line.length == 0
    set_binary_mode @content_length
  end
end