Path: blob/master/lib/rex/proto/http/server_client.rb
19612 views
# -*- coding: binary -*-1require 'rex/socket'234module Rex5module Proto6module Http78###9#10# Runtime extension of the HTTP clients that connect to the server.11#12###13module ServerClient1415#16# Initialize a new request instance.17#18def init_cli(server)19self.request = Request.new20self.server = server21self.keepalive = false22end2324#25# Resets the parsing state.26#27def reset_cli28self.request.reset29end3031#32# Transmits a response and adds the appropriate headers.33#34def send_response(response)35# Set the connection to close or keep-alive depending on what the client36# can support.37response['Connection'] = (keepalive) ? 'Keep-Alive' : 'close'3839# Add any other standard response headers.40server.add_response_headers(response)4142# Send it off.43put(response.to_s)44end4546#47# The current request context.48#49attr_accessor :request50#51# Boolean that indicates whether or not the connection supports keep-alive.52#53attr_accessor :keepalive54#55# A reference to the server the client is associated with.56#57attr_accessor :server5859end6061end62end63end646566