Sha256: e463ec88f043621e1abeb9b21445a85d09b502b4778ba29d04ece5ca2a3dc464
Contents?: true
Size: 994 Bytes
Versions: 2
Compression:
Stored size: 994 Bytes
Contents
# -*- encoding: binary -*- class Kcar::Parser # extract trailers that were set in the header object as # an array of arrays # # parser.extract_trailers(hdr) => # [ [ 'Content-MD5', '1B2M2Y8AsgTpgAmY7PhCfg==' ] ] def extract_trailers(hdr) trailers = [] if hdr.kind_of?(Array) t = {} # the HTTP spec (and our parser) guarantees trailers will appear # after the "Trailer" header is inserted in the array hdr.each do |key, value| if key =~ %r{\ATrailer\z}i value.split(/\s*,+\s*/).each do |k| t[k] = true end elsif !t.empty? && key =~ /\A(#{t.keys.join('|')})\z/i k = $1 trailers.concat(value.split(/\n+/).map! { |v| [ k, v ] }) end end elsif t = hdr['Trailer'] t.split(/\s*[,\n]+\s*/).each do |k| value = hdr[k] or next trailers.concat(value.split(/\n+/).map! { |v| [ k, v ] }) end end trailers end end # module Kcar
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kcar-0.7.0 | lib/kcar/parser.rb |
kcar-0.6.0 | lib/kcar/parser.rb |