Class: Arachni::State::HTTP

Inherits:
Object show all
Defined in:
lib/arachni/state/http.rb

Overview

Author:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHTTP

Returns a new instance of HTTP.



23
24
25
26
# File 'lib/arachni/state/http.rb', line 23

def initialize
    @headers    = {}
    @cookie_jar = Arachni::HTTP::CookieJar.new
end

Instance Attribute Details

Returns Cookie-jar for HTTP::Client#cookie_jar.

Returns:



21
22
23
# File 'lib/arachni/state/http.rb', line 21

def cookie_jar
  @cookie_jar
end

#headersHash (readonly)

Returns HTTP headers for the HTTP::Client#headers.

Returns:



17
18
19
# File 'lib/arachni/state/http.rb', line 17

def headers
  @headers
end

Class Method Details

.load(directory) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/arachni/state/http.rb', line 42

def self.load( directory )
    http = new

    %w(headers cookie_jar).each do |attribute|
        http.send(attribute).merge! Marshal.load( IO.binread( "#{directory}/#{attribute}" ) )
    end

    http
end

Instance Method Details

#clearObject



52
53
54
55
# File 'lib/arachni/state/http.rb', line 52

def clear
    @cookie_jar.clear
    @headers.clear
end

#dump(directory) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/arachni/state/http.rb', line 34

def dump( directory )
    FileUtils.mkdir_p( directory )

    %w(headers cookie_jar).each do |attribute|
        IO.binwrite( "#{directory}/#{attribute}", Marshal.dump( send(attribute) ) )
    end
end

#statisticsObject



28
29
30
31
32
# File 'lib/arachni/state/http.rb', line 28

def statistics
    {
        cookies: @cookie_jar.cookies.map(&:to_s).uniq
    }
end