Class: Msf::Auxiliary::Web::HTTP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/auxiliary/web/http.rb

Overview

Wraps a queued HTTP request and the callbacks that should process its response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) {|response| ... } ⇒ Request

Returns a new instance of Request.

Parameters:

Yields:

  • (response)

    Handles the completed response.

Yield Parameters:

  • response (Response)

    The received response.



24
25
26
27
28
29
30
31
# File 'lib/msf/core/auxiliary/web/http.rb', line 24

def initialize( url, opts = {}, &callback )
  @url  = url.to_s.dup
  @opts = opts.dup

  @opts[:method] ||= :get

  @callbacks = [callback].compact
end

Instance Attribute Details

#callbacksObject (readonly)

Returns the value of attribute callbacks.



18
19
20
# File 'lib/msf/core/auxiliary/web/http.rb', line 18

def callbacks
  @callbacks
end

#optsObject (readonly)

Returns the value of attribute opts.



17
18
19
# File 'lib/msf/core/auxiliary/web/http.rb', line 17

def opts
  @opts
end

#urlObject

Returns the value of attribute url.



16
17
18
# File 'lib/msf/core/auxiliary/web/http.rb', line 16

def url
  @url
end

Instance Method Details

#handle_response(response) ⇒ Array<Proc>

Calls each registered callback with the received response.

Parameters:

  • response (Response)

    The response to dispatch.

Returns:

  • (Array<Proc>)

    The stored callbacks.



42
43
44
# File 'lib/msf/core/auxiliary/web/http.rb', line 42

def handle_response( response )
  callbacks.each { |c| c.call response }
end

#methodSymbol

Returns The HTTP verb used when the request is executed.

Returns:

  • (Symbol)

    The HTTP verb used when the request is executed.



34
35
36
# File 'lib/msf/core/auxiliary/web/http.rb', line 34

def method
  opts[:method]
end