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
22839ae9
Commit
22839ae9
authored
Jun 17, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed jsonp response handling.
parent
769acfbd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Response.php
framework/yii/web/Response.php
+4
-4
No files found.
framework/yii/web/Response.php
View file @
22839ae9
...
...
@@ -706,8 +706,7 @@ class Response extends \yii\base\Response
/**
* Prepares for sending the response.
* The default implementation will convert [[data]] into [[content]] and set headers accordingly.
* @throws InvalidParamException if `$format` is not supported
* @throws InvalidConfigException if the formatter for the specified format is invalid
* @throws InvalidConfigException if the formatter for the specified format is invalid or [[format]] is not supported
*/
protected
function
prepare
()
{
...
...
@@ -744,10 +743,11 @@ class Response extends \yii\base\Response
$this
->
getHeaders
()
->
set
(
'Content-Type'
,
'text/javascript; charset='
.
$this
->
charset
);
if
(
is_array
(
$this
->
data
)
&&
isset
(
$this
->
data
[
'data'
],
$this
->
data
[
'callback'
]))
{
$this
->
content
=
sprintf
(
'%s(%s);'
,
$this
->
data
[
'callback'
],
Json
::
encode
(
$this
->
data
[
'data'
]));
break
;
}
else
{
throw
new
InvalidParamException
(
"The 'jsonp' response requires that the data be an array consisting of both 'data' and 'callback' elements."
);
$this
->
content
=
''
;
Yii
::
warning
(
"The 'jsonp' response requires that the data be an array consisting of both 'data' and 'callback' elements."
,
__METHOD__
);
}
break
;
case
self
::
FORMAT_XML
:
$this
->
content
=
Yii
::
createObject
(
XmlResponseFormatter
::
className
())
->
format
(
$this
);
break
;
...
...
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