samedi 23 juillet 2016

Symfony2 - How to get custom header while testing REST API

I'm testing REST-API. In my DefaultTestController

$client = static::createClient();
$crawler = $client->request(
        'GET',
        "someurl",
        [],
        [],
        [
            'HTTP_X_AUTH_TOKEN' => $clientAuthToken,
        ]
    );

In my REST-controller I'm waiting to get x-auth-token header

$request = Request::createFromGlobals();
$authToken = $request->headers->get('x-auth-token'); 

but I don't. Whats I do wrong?

Aucun commentaire:

Enregistrer un commentaire