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
# File 'lib/arachni/http/message.rb', line 39

def initialize( options = {} )
    update( options )

    fail ArgumentError, 'Missing :url.' if url.to_s.empty?
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



69
70
71
72
# File 'lib/arachni/http/message.rb', line 69

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

#scopeScope

Returns:



65
66
67
# File 'lib/arachni/http/message.rb', line 65

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

#update(options) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/arachni/http/message.rb', line 45

def update( options )
    @normalize_url = options[:normalize_url]

    # Headers are necessary for subsequent operations to set them first.
    @headers = Headers.new( options[:headers] || {} )

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