lib/footrest/response_middleware.rb in footrest-0.3.1 vs lib/footrest/response_middleware.rb in footrest-0.4.1
- old
+ new
@@ -53,12 +53,17 @@
body
end
end
def response_type(env)
- type = env[:response_headers][CONTENT_TYPE].to_s
- type = type.split(';', 2).first if type.index(';')
- type
+ if env[:response_headers]
+ type = env[:response_headers][CONTENT_TYPE].to_s
+ type = type.split(';', 2).first if type.index(';')
+ type
+ else
+ warn("response_headers are nil. Did you use http when you meant https?")
+ nil
+ end
end
def process_response_type?(type)
@content_types.empty? or @content_types.any? { |pattern|
pattern.is_a?(Regexp) ? type =~ pattern : type == pattern
\ No newline at end of file