Skip to content

Commit

Permalink
Adjust headers for JSON response.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Jun 1, 2019
1 parent 71af4c4 commit 2e9e179
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Middleware/AjaxMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function _redirect(ServerRequest $request, Response $response) {

$response = $response->withStatus(200)
->withoutHeader('Location')
->withHeader('Content-Type', 'application/json; charset=' . $response->getCharset())
->withHeader('Content-Type', 'application/json')
->withStringBody($json);

return $response;
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/Component/AjaxComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testDefaults() {
$this->Controller->redirect('/');
$expected = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expected, $this->Controller->response->getHeaders());
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testSetVarsWithRedirect() {
$this->Controller->redirect('/', 301);
$expected = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expected, $this->Controller->response->getHeaders());
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Middleware/AjaxMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testDefaultsRender() {

$expectedHeaders = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expectedHeaders, $result->getHeaders());
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testDefaultsRedirect() {

$expectedHeaders = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expectedHeaders, $result->getHeaders());
Expand Down Expand Up @@ -230,7 +230,7 @@ public function testActions() {

$expectedHeaders = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expectedHeaders, $result->getHeaders());
Expand Down Expand Up @@ -288,7 +288,7 @@ public function testSetVars() {

$expectedHeaders = [
'Content-Type' => [
'application/json; charset=UTF-8',
'application/json',
],
];
$this->assertSame($expectedHeaders, $result->getHeaders());
Expand Down

0 comments on commit 2e9e179

Please sign in to comment.