Class: Rex::Proto::Http::Response
- Defined in:
- lib/rex/proto/http/response.rb
Overview
HTTP response class.
Defined Under Namespace
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#message ⇒ Object
Returns the value of attribute message.
-
#proto ⇒ Object
Returns the value of attribute proto.
-
#request ⇒ Object
Used to store a copy of the original request.
Attributes inherited from Packet
#auto_cl, #body, #bufq, #chunk_max_size, #chunk_min_size, #compress, #error, #headers, #incomplete, #max_data, #state, #transfer_chunked
Instance Method Summary collapse
-
#cmd_string ⇒ Object
Returns the response based command string.
-
#initialize(code = 200, message = 'OK', proto = DefaultProtocol) ⇒ Response
constructor
Constructage of the HTTP response with the supplied code, message, and protocol.
-
#update_cmd_parts(str) ⇒ Object
Updates the various parts of the HTTP response command string.
Methods inherited from Packet
#[], #[]=, #chunk, #completed?, #from_s, #parse, #reset, #reset_except_queue, #to_s
Constructor Details
#initialize(code = 200, message = 'OK', proto = DefaultProtocol) ⇒ Response
Constructage of the HTTP response with the supplied code, message, and protocol.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rex/proto/http/response.rb', line 42 def initialize(code = 200, = 'OK', proto = DefaultProtocol) super() self.code = code.to_i self. = 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 |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
83 84 85 |
# File 'lib/rex/proto/http/response.rb', line 83 def code @code end |
#message ⇒ Object
Returns the value of attribute message.
84 85 86 |
# File 'lib/rex/proto/http/response.rb', line 84 def @message end |
#proto ⇒ Object
Returns the value of attribute proto.
85 86 87 |
# File 'lib/rex/proto/http/response.rb', line 85 def proto @proto end |
#request ⇒ Object
Used to store a copy of the original request
80 81 82 |
# File 'lib/rex/proto/http/response.rb', line 80 def request @request end |
Instance Method Details
#cmd_string ⇒ Object
Returns the response based command string.
73 74 75 |
# File 'lib/rex/proto/http/response.rb', line 73 def cmd_string "HTTP\/#{proto} #{code}#{( and .length > 0) ? ' ' + : ''}\r\n" end |
#update_cmd_parts(str) ⇒ Object
Updates the various parts of the HTTP response command string.
60 61 62 63 64 65 66 67 68 |
# 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. = md[3].gsub(/\r/, '') self.code = md[2].to_i self.proto = md[1] else raise RuntimeError, "Invalid response command string", caller end end |