Fix on CORS

former way to get content type header was buggy
so was preventing to allow us to POST files using
CORS

Change-Id: I92d2d2184c24673c3d15ce4fe96b76e80b641534
This commit is contained in:
Sebastian Marcet 2017-12-11 14:34:50 -03:00
parent a57b59820d
commit 0aff920cc5
2 changed files with 11 additions and 4 deletions

View File

@ -49,10 +49,11 @@ class CORSMiddleware
'origin',
);
protected static $simple_content_header_values = array(
protected static $simple_content_header_values = [
'application/x-www-form-urlencode',
'multipart/form-data',
'text/plain');
'text/plain'
];
/**
* A method is said to be a simple method if it is a case-sensitive match for one of the following:
@ -459,7 +460,12 @@ class CORSMiddleware
$type = CORSRequestPreflightType::UNKNOWN;
$http_method = $request->getMethod();
$content_type = strtolower($request->getContentType());
$content_type = $request->headers->has('Content-Type') ? strtolower( $request->headers->get('Content-Type')) : null;
if (false !== $pos = strpos($content_type, ';')) {
$content_type = substr($content_type, 0, $pos);
}
$http_method = strtoupper($http_method);
if ($http_method === 'OPTIONS' && $request->headers->has('Access-Control-Request-Method'))

View File

@ -19,7 +19,8 @@
"guzzlehttp/guzzle": "^6.3",
"google/apiclient": "^2.2",
"smarcet/caldavclient": "dev-master",
"smarcet/outlook-rest-client": "dev-master"
"smarcet/outlook-rest-client": "dev-master",
"idct/sftp-client": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.4",