Allow Content-Length header to be received and sent in CORS requests
This commit is contained in:
parent
b40b4d4df3
commit
9ccd1e10be
@ -9,11 +9,13 @@ class Api::ApplicationController < ApplicationController
|
||||
request.headers['Origin'] :
|
||||
''
|
||||
headers['Access-Control-Allow-Credentials'] = 'true'
|
||||
headers['Access-Control-Expose-Headers'] = 'Content-Length'
|
||||
end
|
||||
|
||||
def cor_preflight
|
||||
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE'
|
||||
headers['Access-Control-Allow-Headers'] = 'Content-Type, X-Requested-With'
|
||||
headers['Access-Control-Allow-Headers'] =
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ describe Api::ApplicationController do
|
||||
it 'sets Access-Control-Allow-Methods header' do
|
||||
options :index
|
||||
response.headers['Access-Control-Allow-Headers'].should ==
|
||||
'Content-Type, X-Requested-With'
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,7 +28,7 @@ feature 'API cross origin request' do
|
||||
response.headers['Access-Control-Allow-Methods'].should ==
|
||||
'GET, POST, PUT, DELETE'
|
||||
response.headers['Access-Control-Allow-Headers'].should ==
|
||||
'Content-Type, X-Requested-With'
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
end
|
||||
|
||||
scenario 'basic request' do
|
||||
@ -39,6 +39,7 @@ feature 'API cross origin request' do
|
||||
|
||||
response.headers['Access-Control-Allow-Origin'].should == origin
|
||||
response.headers['Access-Control-Allow-Credentials'].should == 'true'
|
||||
response.headers['Access-Control-Expose-Headers'].should == 'Content-Length'
|
||||
end
|
||||
|
||||
scenario 'request without origin' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user