Class: Typhoeus::Response
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
- #content_type ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(*args) ⇒ Response
constructor
A new instance of Response.
- #location ⇒ Object
- #old_initialize ⇒ Object
- #redirection? ⇒ Boolean
-
#to_hash ⇒ Hash
Converts self to hash.
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_type ⇒ Object
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 |
#location ⇒ Object
42 43 44 |
# File 'lib/arachni/typhoeus/response.rb', line 42 def location find_header_value( 'location' ) end |
#old_initialize ⇒ Object
20 |
# File 'lib/arachni/typhoeus/response.rb', line 20 alias :old_initialize :initialize |
#redirection? ⇒ Boolean
46 47 48 |
# File 'lib/arachni/typhoeus/response.rb', line 46 def redirection? (300..399).include?( @code ) || !location.nil? end |
#to_hash ⇒ Hash
Returns 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 |