Parent

Patron::Response

Represents the response from the HTTP server.

Attributes

url[R]
status[R]
status_line[R]
redirect_count[R]
body[R]
headers[R]

Public Class Methods

new() click to toggle source
    # File lib/patron/response.rb, line 31
31:     def initialize
32:       @headers = {}
33:     end

Public Instance Methods

inspect() click to toggle source
    # File lib/patron/response.rb, line 37
37:     def inspect
38:       # Avoid spamming the console with the header and body data
39:       "#<Patron::Response @status_line='#{@status_line}'>"
40:     end

Private Instance Methods

parse_headers(header_data) click to toggle source

Called by the C code to parse and set the headers

    # File lib/patron/response.rb, line 45
45:     def parse_headers(header_data)
46:       header_data.split(/\r\n/).each do |header|
47:         if header =~ %^HTTP/1.[01]|
48:           @status_line = header.strip
49:         else
50:           parts = header.split(':', 2)
51:           unless parts.empty?
52:             parts[1].strip! unless parts[1].nil?
53:             if @headers.has_key?(parts[0])
54:               @headers[parts[0]] = [@headers[parts[0]]] unless @headers[parts[0]].kind_of? Array
55:               @headers[parts[0]] << parts[1]
56:             else
57:               @headers[parts[0]] = parts[1]
58:             end
59:           end
60:         end
61:       end
62:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.