class Stella::Report::Headers

Public Instance Methods

empty?() click to toggle source
# File lib/stella/report.rb, line 270
def empty?
  @response_headers.to_s.empty?
end
init(*args) click to toggle source
# File lib/stella/report.rb, line 243
def init *args
  # TODO: This doesn't seem to be called anymore.
  @request_headers_hash = {}
  @response_headers_hash = {}
end
process(filter={}) click to toggle source
# File lib/stella/report.rb, line 248
def process(filter={})
  return if report.content.log.empty?
  @request_headers = report.content.log.first.request_headers
  @response_headers = report.content.log.first.response_headers
  @request_headers_digest = report.content.log.first.request_headers.digest
  @response_headers_digest = report.content.log.first.response_headers.digest
  processed!
end
request_header(name=nil) click to toggle source
# File lib/stella/report.rb, line 256
def request_header name=nil
  @request_headers_hash ||= {}
  if @request_headers_hash.empty? && @request_headers
    @request_headers_hash = parse(@request_headers)
  end
  name.nil? ? @request_headers_hash : @request_headers_hash[name.to_s.upcase]
end
response_header(name=nil) click to toggle source
# File lib/stella/report.rb, line 263
def response_header name=nil
  @response_headers_hash ||= {}
  if @response_headers_hash.empty? && @response_headers
    @response_headers_hash = parse(@response_headers)
  end
  name.nil? ? @response_headers_hash : @response_headers_hash[name.to_s.upcase]
end

Private Instance Methods

parse(str) click to toggle source
# File lib/stella/report.rb, line 274
def parse str
  headers = {}
  str.split(CRLF).each do|line|
    key, value = line.split(/\s*:\s*/, 2)
    headers[key.upcase] = value
  end
  headers
end