Class: Thin::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/thin_extensions.rb

Instance Method Summary collapse

Instance Method Details

#receive_data(data) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/thin_extensions.rb', line 29

def receive_data(data)
  trace { data }

  case @serving
  when :websocket
    callback = @request.env[Thin::Request::WEBSOCKET_RECEIVE_CALLBACK]
    callback.call(data) if callback
  else
    if @request.parse(data)
      if @request.websocket?
        @response.persistent!
        @response.websocket_upgrade_data = @request.websocket_upgrade_data
        @serving = :websocket
      end

      process
    end
  end
rescue Thin::InvalidRequest => e
  log "!! Invalid request"
  log_error e
  close_connection
end