Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from fojas/master

FIxed error when json_csrf tries to strip nil
  • Loading branch information...
commit 89f9ab44d8476e52553b3165d10c3113b87c624d 2 parents 644f85f + 4667263
@rkh rkh authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  lib/rack/protection/json_csrf.rb
  2. +9 −0 spec/json_csrf_spec.rb
View
2  lib/rack/protection/json_csrf.rb
@@ -15,7 +15,7 @@ class JsonCsrf < Base
def call(env)
status, headers, body = app.call(env)
- if headers['Content-Type'].to_s.split(';', 2).first.strip == 'application/json'
+ if headers['Content-Type'].to_s.split(';', 2).first =~ /^\s*application\/json\s*$/
result = react(env) if referrer(env) != Request.new(env).host
end
result or [status, headers, body]
View
9 spec/json_csrf_spec.rb
@@ -20,4 +20,13 @@
get('/', {}).should be_ok
end
end
+
+ describe 'not json response' do
+
+ it "accepts get requests with 304 headers" do
+ mock_app { |e| [304, {}, []]}
+ get('/', {}).status.should == 304
+ end
+
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.