File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -97,12 +97,16 @@ protected function update()
97
97
{
98
98
if (null !== $ this ->callback ) {
99
99
// Not using application/javascript for compatibility reasons with older browsers.
100
- $ this ->headers ->set ('Content-Type ' , 'text/javascript ' , true );
100
+ $ this ->headers ->set ('Content-Type ' , 'text/javascript ' );
101
101
102
102
return $ this ->setContent (sprintf ('%s(%s); ' , $ this ->callback , $ this ->data ));
103
103
}
104
104
105
- $ this ->headers ->set ('Content-Type ' , 'application/json ' , false );
105
+ // Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback)
106
+ // in order to not overwrite a custom definition.
107
+ if (!$ this ->headers ->has ('Content-Type ' ) || 'text/javascript ' === $ this ->headers ->get ('Content-Type ' )) {
108
+ $ this ->headers ->set ('Content-Type ' , 'application/json ' );
109
+ }
106
110
107
111
return $ this ->setContent ($ this ->data );
108
112
}
You can’t perform that action at this time.
0 commit comments