Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from methylbro/fix-response-body-plain-text
Browse files Browse the repository at this point in the history
fix #1 Content-Type: Json and responses content in plain text
  • Loading branch information
methylbro authored Oct 10, 2017
2 parents d2914d2 + db4ed48 commit 007a99e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Binary file added .DS_Store
Binary file not shown.
9 changes: 5 additions & 4 deletions src/Controller/LaPresseLibreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Mediapart\Bundle\LaPresseLibreBundle\Handler;

Expand Down Expand Up @@ -44,10 +43,12 @@ public function __construct(Handler $handler)
*/
public function executeAction(Request $request)
{
$headers = $this->handler->getHttpResponseHeaders();

$headers = array_merge(
$this->handler->getHttpResponseHeaders(),
['Content-Type' => 'application/json']
);
try {
$response = new JsonResponse(
$response = new Response(
$this->handler->process($request),
Response::HTTP_OK,
$headers
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Controller/LaPresseLibreControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testSuccess()
$response = $controller->executeAction($request);

$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
$this->assertEquals($result, json_decode($response->getContent()));
$this->assertEquals($result, $response->getContent());
}

/**
Expand Down

0 comments on commit 007a99e

Please sign in to comment.