Class: Patron::Response
- Inherits:
-
Object
- Object
- Patron::Response
- Defined in:
- lib/patron/response.rb
Overview
Represents the response from the HTTP server.
Instance Attribute Summary (collapse)
-
- (Object) body
readonly
Returns the value of attribute body.
-
- (Object) charset
readonly
Returns the value of attribute charset.
-
- (Object) headers
readonly
Returns the value of attribute headers.
-
- (Object) redirect_count
readonly
Returns the value of attribute redirect_count.
-
- (Object) status
readonly
Returns the value of attribute status.
-
- (Object) status_line
readonly
Returns the value of attribute status_line.
-
- (Object) url
readonly
Returns the value of attribute url.
Instance Method Summary (collapse)
-
- (Response) initialize(url, status, redirect_count, header_data, body, default_charset = nil)
constructor
A new instance of Response.
- - (Object) inspect
- - (Object) marshal_dump
- - (Object) marshal_load(data)
Constructor Details
- (Response) initialize(url, status, redirect_count, header_data, body, default_charset = nil)
A new instance of Response
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/patron/response.rb', line 31 def initialize(url, status, redirect_count, header_data, body, default_charset = nil) # Don't let a response clear out the default charset, which would cause encoding to fail default_charset = "ASCII-8BIT" unless default_charset @url = url @status = status @redirect_count = redirect_count @body = body @charset = determine_charset(header_data, body) || default_charset [url, header_data].each do |attr| convert_to_default_encoding!(attr) end parse_headers(header_data) if @headers["Content-Type"] && @headers["Content-Type"][0, 5] == "text/" convert_to_default_encoding!(@body) end end |
Instance Attribute Details
- (Object) body (readonly)
Returns the value of attribute body
51 52 53 |
# File 'lib/patron/response.rb', line 51 def body @body end |
- (Object) charset (readonly)
Returns the value of attribute charset
51 52 53 |
# File 'lib/patron/response.rb', line 51 def charset @charset end |
- (Object) headers (readonly)
Returns the value of attribute headers
51 52 53 |
# File 'lib/patron/response.rb', line 51 def headers @headers end |
- (Object) redirect_count (readonly)
Returns the value of attribute redirect_count
51 52 53 |
# File 'lib/patron/response.rb', line 51 def redirect_count @redirect_count end |
- (Object) status (readonly)
Returns the value of attribute status
51 52 53 |
# File 'lib/patron/response.rb', line 51 def status @status end |
- (Object) status_line (readonly)
Returns the value of attribute status_line
51 52 53 |
# File 'lib/patron/response.rb', line 51 def status_line @status_line end |
- (Object) url (readonly)
Returns the value of attribute url
51 52 53 |
# File 'lib/patron/response.rb', line 51 def url @url end |
Instance Method Details
- (Object) inspect
53 54 55 56 |
# File 'lib/patron/response.rb', line 53 def inspect # Avoid spamming the console with the header and body data "#<Patron::Response @status_line='#{@status_line}'>" end |
- (Object) marshal_dump
58 59 60 |
# File 'lib/patron/response.rb', line 58 def marshal_dump [@url, @status, @status_line, @redirect_count, @body, @headers, @charset] end |
- (Object) marshal_load(data)
62 63 64 |
# File 'lib/patron/response.rb', line 62 def marshal_load(data) @url, @status, @status_line, @redirect_count, @body, @headers, @charset = data end |