Module: Rex::Proto::Http::ServerClient

Defined in:
lib/rex/proto/http/server.rb

Overview

Runtime extension of the HTTP clients that connect to the server.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keepaliveObject

Boolean that indicates whether or not the connection supports keep-alive.


55
56
57
# File 'lib/rex/proto/http/server.rb', line 55

def keepalive
  @keepalive
end

#requestObject

The current request context.


51
52
53
# File 'lib/rex/proto/http/server.rb', line 51

def request
  @request
end

#serverObject

A reference to the server the client is associated with.


59
60
61
# File 'lib/rex/proto/http/server.rb', line 59

def server
  @server
end

Instance Method Details

#init_cli(server) ⇒ Object

Initialize a new request instance.


20
21
22
23
24
# File 'lib/rex/proto/http/server.rb', line 20

def init_cli(server)
  self.request   = Request.new
  self.server    = server
  self.keepalive = false
end

#reset_cliObject

Resets the parsing state.


29
30
31
# File 'lib/rex/proto/http/server.rb', line 29

def reset_cli
  self.request.reset
end

#send_response(response) ⇒ Object

Transmits a response and adds the appropriate headers.


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rex/proto/http/server.rb', line 36

def send_response(response)
  # Set the connection to close or keep-alive depending on what the client
  # can support.
  response['Connection'] = (keepalive) ? 'Keep-Alive' : 'close'

  # Add any other standard response headers.
  server.add_response_headers(response)

  # Send it off.
  put(response.to_s)
end