1 # -*- encoding: binary -*-
4 # extract trailers that were set in the header object as
7 # parser.extract_trailers(hdr) =>
8 # [ [ 'Content-MD5', '1B2M2Y8AsgTpgAmY7PhCfg==' ] ]
9 def extract_trailers(hdr)
12 if hdr.kind_of?(Array)
15 # the HTTP spec (and our parser) guarantees trailers will appear
16 # after the "Trailer" header is inserted in the array
17 hdr.each do |key, value|
18 if key =~ %r{\ATrailer\z}i
19 value.split(/\s*,+\s*/).each do |k|
22 elsif false == t.empty? && key =~ /\A(#{t.keys.join('|')})\z/i
24 trailers.concat(value.split(/\n+/).map! { |v| [ k, v ] })
27 elsif t = hdr['Trailer']
28 t.split(/\s*[,\n]+\s*/).each do |k|
29 value = hdr[k] or next
30 trailers.concat(value.split(/\n+/).map! { |v| [ k, v ] })