lib/pdfkit/middleware.rb in pdfkit-0.8.7 vs lib/pdfkit/middleware.rb in pdfkit-0.8.7.1

- old
+ new

@@ -20,11 +20,12 @@ 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/ + content_type_header = headers.has_key?('Content-Type') ? 'Content-Type' : 'content-type' + if rendering_pdf? && headers[content_type_header] =~ /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) @@ -47,10 +48,10 @@ 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_type_header] = 'application/pdf' headers['content-disposition'] ||= @conditions[:disposition] || 'inline' end rescue StandardError => e status = 500 response = [e.message]