Skip to content

Commit

Permalink
Land #18564, Fix an uninitialized constant error in capture/http
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 committed Nov 22, 2023
2 parents dd701c1 + e9d6bab commit bccd906
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 53 deletions.
53 changes: 0 additions & 53 deletions lib/rex/proto/http/server.rb
Expand Up @@ -6,59 +6,6 @@ module Rex
module Proto
module Http

###
#
# Runtime extension of the HTTP clients that connect to the server.
#
###
module ServerClient

#
# Initialize a new request instance.
#
def init_cli(server)
self.request = Request.new
self.server = server
self.keepalive = false
end

#
# Resets the parsing state.
#
def reset_cli
self.request.reset
end

#
# Transmits a response and adds the appropriate headers.
#
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

#
# The current request context.
#
attr_accessor :request
#
# Boolean that indicates whether or not the connection supports keep-alive.
#
attr_accessor :keepalive
#
# A reference to the server the client is associated with.
#
attr_accessor :server

end

###
#
# Acts as an HTTP server, processing requests and dispatching them to
Expand Down
64 changes: 64 additions & 0 deletions lib/rex/proto/http/server_client.rb
@@ -0,0 +1,64 @@
# -*- coding: binary -*-
require 'rex/socket'


module Rex
module Proto
module Http

###
#
# Runtime extension of the HTTP clients that connect to the server.
#
###
module ServerClient

#
# Initialize a new request instance.
#
def init_cli(server)
self.request = Request.new
self.server = server
self.keepalive = false
end

#
# Resets the parsing state.
#
def reset_cli
self.request.reset
end

#
# Transmits a response and adds the appropriate headers.
#
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

#
# The current request context.
#
attr_accessor :request
#
# Boolean that indicates whether or not the connection supports keep-alive.
#
attr_accessor :keepalive
#
# A reference to the server the client is associated with.
#
attr_accessor :server

end

end
end
end

0 comments on commit bccd906

Please sign in to comment.