Class: HTTPkit::Server::KeepAliveHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/httpkit/server/keep_alive_handler.rb

Constant Summary collapse

CONNECTION =
'Connection'.freeze
CLOSE =
'close'.freeze
KEEP_ALIVE =
'keep-alive'.freeze

Instance Method Summary collapse

Instance Method Details

#finish(request) ⇒ Object


28
29
30
# File 'lib/httpkit/server/keep_alive_handler.rb', line 28

def finish(request)
  @requests.delete(sequence(request))
end

#respond(request, response) ⇒ Object


18
19
20
21
22
23
24
25
26
# File 'lib/httpkit/server/keep_alive_handler.rb', line 18

def respond(request, response)
  synchronize_responses(request)

  if close_connection?(request)
    yield request, close_response(response)
  else
    yield request, keep_alive_response(response)
  end
end

#serve(request, served) ⇒ Object


14
15
16
# File 'lib/httpkit/server/keep_alive_handler.rb', line 14

def serve(request, served)
  @requests[sequence(request)] = served
end

#setup(_, server, _) ⇒ Object


9
10
11
12
# File 'lib/httpkit/server/keep_alive_handler.rb', line 9

def setup(_, server, _)
  @server = server
  @requests = {}
end