Crixx93
Crixx93

Reputation: 777

How to change Content Type for Request Header in Symfony 2?

I have this legacy code in Symfony 2. I don't know much about Symfony and I have this requests that have JSON formatted content, but the header has content type: application/x-www-form-urlencoded; charset=UTF-8. I need to change this to application/json, but I can't find where Symfony dispatches the request to the server.

Upvotes: 0

Views: 5119

Answers (1)

Anjana Silva
Anjana Silva

Reputation: 9191

You can do something like this,

use Symfony\Component\HttpFoundation\Response;
$response = new Response();
$response->headers->set('Content-Type', 'text/json');
$response->send();

Also, it is worth referring to Symfony's documentation Symfony HttpFoundation Component

Upvotes: 1

Related Questions