lib/pdfkit/middleware.rb in pdfkit-0.8.6 vs lib/pdfkit/middleware.rb in pdfkit-0.8.7
- old
+ new
@@ -20,11 +20,11 @@
set_request_to_render_as_pdf(env) if render_as_pdf?
status, headers, response = @app.call(env)
begin
- if rendering_pdf? && headers['Content-Type'] =~ /text\/html|application\/xhtml\+xml/
+ if rendering_pdf? && headers['content-type'] =~ /text\/html|application\/xhtml\+xml/
body = response.respond_to?(:body) ? response.body : response.join
body = body.join if body.is_a?(Array)
root_url = root_url(env)
protocol = protocol(env)
@@ -42,16 +42,16 @@
headers.delete('PDFKit-save-pdf')
end
unless @caching
# Do not cache PDFs
- headers.delete('ETag')
- headers.delete('Cache-Control')
+ headers.delete('etag')
+ headers.delete('cache-control')
end
- headers['Content-Length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
- headers['Content-Type'] = 'application/pdf'
- headers['Content-Disposition'] ||= @conditions[:disposition] || 'inline'
+ headers['content-length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
+ headers['content-type'] = 'application/pdf'
+ headers['content-disposition'] ||= @conditions[:disposition] || 'inline'
end
rescue StandardError => e
status = 500
response = [e.message]
end