Sha256: e9574bb135ec78e106be7aced9c450b7a665e7bb503fc268f95549663cb54787
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
# -*- encoding : utf-8 -*- module Pacto module Formats module Legacy module Generator class Filters CONNECTION_CONTROL_HEADERS = %w( Via Server Connection Transfer-Encoding Content-Length ) FRESHNESS_HEADERS = %w( Date Last-Modified ETag ) HEADERS_TO_FILTER = CONNECTION_CONTROL_HEADERS + FRESHNESS_HEADERS def filter_request_headers(request, response) # FIXME: Do we need to handle all these cases in real situations, or just because of stubbing? vary_headers = response.headers['vary'] || response.headers['Vary'] || [] vary_headers = [vary_headers] if vary_headers.is_a? String vary_headers = vary_headers.map do |h| h.split(',').map(&:strip) end.flatten request.headers.select do |header| vary_headers.map(&:downcase).include? header.downcase end end def filter_response_headers(_request, response) Pacto::Extensions.normalize_header_keys(response.headers).reject do |header| (HEADERS_TO_FILTER.include? header) || (header.start_with?('X-')) end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | lib/pacto/formats/legacy/generator/filters.rb |
pacto-0.4.0.rc2 | lib/pacto/formats/legacy/generator/filters.rb |