Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
9d25418b
Commit
9d25418b
authored
Jul 04, 2014
by
Philippe Gaultier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove static functions
parent
be2d5530
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Cors.php
framework/filters/Cors.php
+5
-5
No files found.
framework/filters/Cors.php
View file @
9d25418b
...
...
@@ -127,7 +127,7 @@ class Cors extends ActionFilter
$headers
=
[];
$requestHeaders
=
array_keys
(
$this
->
cors
);
foreach
(
$requestHeaders
as
$headerField
)
{
$serverField
=
static
::
headerizeToPhp
(
$headerField
);
$serverField
=
$this
->
headerizeToPhp
(
$headerField
);
$headerData
=
isset
(
$_SERVER
[
$serverField
])
?
$_SERVER
[
$serverField
]
:
null
;
if
(
$headerData
!==
null
)
{
$headers
[
$headerField
]
=
$headerData
;
...
...
@@ -182,7 +182,7 @@ class Cors extends ActionFilter
if
(
$type
===
'Method'
)
{
$responseHeaders
[
$responseHeaderField
]
=
strtoupper
(
$requestHeaders
[
$requestHeaderField
]);
}
elseif
(
$type
===
'Headers'
)
{
$responseHeaders
[
$responseHeaderField
]
=
static
::
headerize
(
$requestHeaders
[
$requestHeaderField
]);
$responseHeaders
[
$responseHeaderField
]
=
$this
->
headerize
(
$requestHeaders
[
$requestHeaderField
]);
}
}
else
{
$requestedData
=
preg_split
(
"/[\s,]+/"
,
$requestHeaders
[
$requestHeaderField
],
-
1
,
PREG_SPLIT_NO_EMPTY
);
...
...
@@ -191,7 +191,7 @@ class Cors extends ActionFilter
if
(
$type
===
'Method'
)
{
$req
=
strtoupper
(
$req
);
}
elseif
(
$type
===
'Headers'
)
{
$req
=
static
::
headerize
(
$req
);
$req
=
$this
->
headerize
(
$req
);
}
if
(
in_array
(
$req
,
$this
->
cors
[
$requestHeaderField
]))
{
$acceptedData
[]
=
$req
;
...
...
@@ -226,7 +226,7 @@ class Cors extends ActionFilter
* @param string $string string to convert
* @return string the result in "header" format
*/
protected
static
function
headerize
(
$string
)
protected
function
headerize
(
$string
)
{
$headers
=
preg_split
(
"/[\s,]+/"
,
$string
,
-
1
,
PREG_SPLIT_NO_EMPTY
);
$headers
=
array_map
(
function
(
$element
)
{
...
...
@@ -242,7 +242,7 @@ class Cors extends ActionFilter
* @param string $string string to convert
* @return string the result in "php $_SERVER header" format
*/
protected
static
function
headerizeToPhp
(
$string
)
protected
function
headerizeToPhp
(
$string
)
{
return
'HTTP_'
.
strtoupper
(
str_replace
([
' '
,
'-'
],
[
'_'
,
'_'
],
$string
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment