module Patron::HeaderParser
def self.parse(string_of_headers_from_multiple_responses_in_sequence)
-
the
(String
) -- string of headers, with responses delimited by empty lines. All lines must end with CRLF
def self.parse(string_of_headers_from_multiple_responses_in_sequence) responses = [] string_of_headers_from_multiple_responses_in_sequence.each_line do |matched_line| if matched_line =~ HTTP_STATUS_LINE_START_RE responses << SingleResponseHeaders.new(matched_line.strip, []) elsif matched_line =~ HEADER_LINE_START_RE raise "Header should follow an HTTP status line" unless responses.any? responses[-1].headers << matched_line.strip end # else it is the end of the headers for the request end responses end