rack-xslview 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rack-xslview.rb +10 -6
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/rack-xslview.rb
CHANGED
@@ -19,13 +19,18 @@ module Rack
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(env)
|
22
|
+
|
22
23
|
# No matter what, @app will be called
|
23
|
-
status, headers, body = @app.call(env)
|
24
|
+
status, headers, body = original_response = @app.call(env)
|
25
|
+
|
26
|
+
return original_response if (status == 304 || status == 204)
|
27
|
+
|
28
|
+
return original_response unless headers["Content-Type"].to_s.match(/(ht|x)ml/)
|
24
29
|
|
25
30
|
# If setup includes paths to exclude from xslt processing, check them
|
26
31
|
checknoxsl(env) if @options[:noxsl]
|
27
32
|
|
28
|
-
# Obtain entire request body,
|
33
|
+
# Obtain entire request body, ensuring sure it can be processed
|
29
34
|
myxml = getResponse(body)
|
30
35
|
|
31
36
|
# Should XSL file be reloaded?
|
@@ -56,8 +61,8 @@ module Rack
|
|
56
61
|
[status, headers, newbody]
|
57
62
|
|
58
63
|
rescue XSLViewError
|
59
|
-
# TODO
|
60
|
-
|
64
|
+
# TODO Log: "Rack XSLView not processed" if env['RACK_ENV'] == 'development'
|
65
|
+
original_response
|
61
66
|
end
|
62
67
|
|
63
68
|
private
|
@@ -78,7 +83,7 @@ module Rack
|
|
78
83
|
end
|
79
84
|
def checkForXml(x)
|
80
85
|
# Abort processing if content cannot be processed by libxslt
|
81
|
-
raise XSLViewError unless x[0
|
86
|
+
raise XSLViewError unless x[0] == '<'
|
82
87
|
if @options[:excludehtml] == true
|
83
88
|
raise XSLViewError if x.include? '<html'
|
84
89
|
end
|
@@ -95,4 +100,3 @@ module Rack
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
end
|
98
|
-
|