lib/rack/xsl.rb in rack-xsl-0.2.6 vs lib/rack/xsl.rb in rack-xsl-0.2.7

- old
+ new

@@ -14,10 +14,11 @@ require 'rexml/document' @xslt = XML::XSLT.new() @xslt.xsl = REXML::Document.new '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"><xsl:import href="http://github.com/docunext/1bb02b59/raw/master/standard.html.xsl"/><xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/></xsl:stylesheet>' else @xslt = @options[:myxsl] + @xslt.xsl = REXML::Document.new @options[:xslfile] end end def call(env) # No matter what, @app will be called @@ -74,10 +75,13 @@ # Content type override? unless @options[:content_type].nil? headers["Content-Type"] = @options[:content_type] end + # Cache control override? + headers["Cache-Control"] = @options[:cache_control] if @options.has_key?(:cache_control) + [status, headers, newbody] rescue RackXSLError # TODO Log: "Rack XSL not processed" if env['RACK_ENV'] == 'development' original_response @@ -88,9 +92,10 @@ @options[:noxsl].each { |path| raise RackXSLError if env["PATH_INFO"].index(path) } end def getResponse(body) + return body unless body.respond_to?(:each) newbody = [] body.each { |part| # Only check the first chunk to ensure 1) its not HTML and 2) its XML checkForXml(part) if newbody.empty? newbody << part.to_s