Class: Typhoeus::Response

Inherits:
Object show all
Defined in:
lib/arachni/typhoeus/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Response

Returns a new instance of Response.



21
22
23
24
# File 'lib/arachni/typhoeus/response.rb', line 21

def initialize( *args )
    old_initialize( *args )
    @body = @body.repack if @body
end

Instance Method Details

#[](k) ⇒ Object



26
27
28
# File 'lib/arachni/typhoeus/response.rb', line 26

def []( k )
    find_header_value( k )
end

#[]=(k, v) ⇒ Object



30
31
32
# File 'lib/arachni/typhoeus/response.rb', line 30

def []=( k, v )
    headers_hash[find_header_field( k ) || k] = v
end

#content_typeObject



38
39
40
# File 'lib/arachni/typhoeus/response.rb', line 38

def content_type
    find_header_value( 'content-type' )
end

#each(&block) ⇒ Object



34
35
36
# File 'lib/arachni/typhoeus/response.rb', line 34

def each( &block )
    headers_hash.each( &block )
end

#locationObject



42
43
44
# File 'lib/arachni/typhoeus/response.rb', line 42

def location
    find_header_value( 'location' )
end

#old_initializeObject



20
# File 'lib/arachni/typhoeus/response.rb', line 20

alias :old_initialize :initialize

#redirection?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/arachni/typhoeus/response.rb', line 46

def redirection?
    (300..399).include?( @code ) || !location.nil?
end

#to_hashHash

Returns converts self to hash.

Returns:

  • (Hash)

    converts self to hash



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/arachni/typhoeus/response.rb', line 51

def to_hash
    hash = {}
    instance_variables.each do |var|
        hash[var.to_s.gsub( /@/, '' )] = instance_variable_get( var )
    end

    hash['headers_hash'] = {}
    headers_hash.to_hash.each_pair { |k, v| hash['headers_hash'][k] = v }

    hash.delete( 'request' )
    hash
end