Parent

Class/Module Index [+]

Quicksearch

Rex::Proto::Http::Response::UnitTest::Klass

HTTP response class.

Attributes

code[RW]
message[RW]
proto[RW]
request[RW]

Used to store a copy of the original request

Public Class Methods

new(code = 200, message = 'OK', proto = DefaultProtocol) click to toggle source

Constructage of the HTTP response with the supplied code, message, and protocol.

# File lib/rex/proto/http/response.rb, line 42
def initialize(code = 200, message = 'OK', proto = DefaultProtocol)
        super()

        self.code    = code.to_i
        self.message = message
        self.proto   = proto

        # Default responses to auto content length on
        self.auto_cl = true

        # default chunk sizes (if chunked is used)
        self.chunk_min_size = 1
        self.chunk_max_size = 10
end

Public Instance Methods

cmd_string() click to toggle source

Returns the response based command string.

# File lib/rex/proto/http/response.rb, line 73
def cmd_string
        "HTTP\/#{proto} #{code}#{(message and message.length > 0) ? ' ' + message : ''}\r\n"
end
update_cmd_parts(str) click to toggle source

Updates the various parts of the HTTP response command string.

# File lib/rex/proto/http/response.rb, line 60
def update_cmd_parts(str)
        if (md = str.match(/HTTP\/(.+?)\s+(\d+)\s?(.+?)\r?\n?$/))
                self.message = md[3].gsub(/\r/, '')
                self.code    = md[2].to_i
                self.proto   = md[1]
        else
                raise RuntimeError, "Invalid response command string", caller
        end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.