Class: Metasploit::Aggregator::Http::Request
- Inherits:
-
Object
- Object
- Metasploit::Aggregator::Http::Request
- Defined in:
- lib/metasploit/aggregator/http/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Class Method Summary collapse
- .from_msgpack(string) ⇒ Object
-
.parked ⇒ Object
provide a default response in Request form.
- .parse_uri(http_request) ⇒ Object
Instance Method Summary collapse
-
#initialize(request_headers, request_body, socket) ⇒ Request
constructor
A new instance of Request.
- #to_msgpack ⇒ Object
Constructor Details
#initialize(request_headers, request_body, socket) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 |
# File 'lib/metasploit/aggregator/http/request.rb', line 9 def initialize(request_headers, request_body, socket) @headers = request_headers @body = request_body @socket = socket end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/metasploit/aggregator/http/request.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/metasploit/aggregator/http/request.rb', line 5 def headers @headers end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
7 8 9 |
# File 'lib/metasploit/aggregator/http/request.rb', line 7 def socket @socket end |
Class Method Details
.from_msgpack(string) ⇒ Object
33 34 35 36 |
# File 'lib/metasploit/aggregator/http/request.rb', line 33 def self.from_msgpack(string) data = MessagePack.load string self.new(data['headers'], data['body'].force_encoding(Encoding::ASCII_8BIT), nil) end |
.parked ⇒ Object
provide a default response in Request form
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/metasploit/aggregator/http/request.rb', line 39 def self.parked() = [] << 'HTTP/1.1 200 OK' << 'Content-Type: application/octet-stream' << 'Connection: close' << 'Server: Apache' << 'Content-Length: 0' << ' ' << ' ' self.new(, '', nil) end |
.parse_uri(http_request) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/metasploit/aggregator/http/request.rb', line 15 def self.parse_uri(http_request) req = http_request.headers[0] parts = req.split(/ /) uri = nil if parts.length >= 2 uri = req.split(/ /)[1] uri = uri.chomp('/') end uri end |
Instance Method Details
#to_msgpack ⇒ Object
26 27 28 29 30 31 |
# File 'lib/metasploit/aggregator/http/request.rb', line 26 def to_msgpack MessagePack.dump ({ :headers => headers, :body => body }) end |