Fixed call strip call on missing Content-Type header

This commit is contained in:
Fojas 2011-08-11 09:38:46 -05:00
parent f7f39fde07
commit 34003df86e
2 changed files with 10 additions and 1 deletions

View File

@ -15,7 +15,7 @@ module Rack
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 File

@ -20,4 +20,13 @@ describe Rack::Protection::JsonCsrf do
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