Symfony functional test - custom headers not passing through

前端 未结 2 684
囚心锁ツ
囚心锁ツ 2020-12-29 19:53

For some reason when i sent a new $client->request the headers I specify get lost:

public function testGetClientsAction()
{
    $client = static::createClien         


        
2条回答
  •  温柔的废话
    2020-12-29 20:13

    I have the same issue and after a little dig through I think it is a feature that BrowserKit currently doesn't support.

    I have logged an issue for it: https://github.com/symfony/symfony/issues/5074

    Update: this is not an issue -- see the comments below

    Sample Code

    Sample request:

    $client->request(
        'GET',
        $url,
        array(),
        array(),
        array(
            'HTTP_X_CUSTOM_VAR' => $var
        )
    );
    

    Fetching the data:

    $request->headers->get('x-custom-var');
    

提交回复
热议问题