Class: Arachni::HTTP::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/http/message.rb,
lib/arachni/http/message/scope.rb

Overview

Author:

Direct Known Subclasses

Request, Response

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Message

Note:

All options will be sent through the class setters whenever possible to allow for normalization.

Returns a new instance of Message.

Parameters:

  • options (Hash) (defaults to: {})

    Message options.

Options Hash (options):

  • :url (String)

    URL.

  • :headers (Hash)

    HTTP headers.

  • :body (String)

    Body.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/arachni/http/message.rb', line 39

def initialize( options = {} )
    options.each do |k, v|
        v = my_dup( v )
        begin
            send( "#{k}=", v )
        rescue NoMethodError
            instance_variable_set( "@#{k}".to_sym, v )
        end
    end

    fail ArgumentError, 'Missing :url.' if url.to_s.empty?

    @headers = Headers.new( @headers )
end

Instance Attribute Details

#bodyString

Returns Request/Response body.

Returns:



26
27
28
# File 'lib/arachni/http/message.rb', line 26

def body
  @body
end

#headersHeaders<String, String>

Returns HTTP headers as a Hash-like object.

Returns:



22
23
24
# File 'lib/arachni/http/message.rb', line 22

def headers
  @headers
end

#urlString

Returns Resource location.

Returns:

  • (String)

    Resource location.



18
19
20
# File 'lib/arachni/http/message.rb', line 18

def url
  @url
end

Instance Method Details

#parsed_urlObject



59
60
61
62
# File 'lib/arachni/http/message.rb', line 59

def parsed_url
    # Don't cache this, that's already handled by the URI parser's own cache.
    Arachni::URI( url )
end

#scopeScope

Returns:



55
56
57
# File 'lib/arachni/http/message.rb', line 55

def scope
    @scope ||= self.class::Scope.new( self )
end