8
Symfony 2로 작성된 HTTP API가 있으며 이에 대한 기능 테스트를하고 있습니다.symfony 2 컨트롤러 테스트가 인증 헤더를 넘길 수 없습니다.
Authorization
헤더를 보내려고하면 수신 된 헤더를 기록 할 때 컨트롤러에 메시지가 수신되지 않습니다. 테스트 컨트롤러에서
:
$client = self::createClient();
$client->insulate();
$headers = array(
'Authorization' => "Bearer {$accessToken}",
'CONTENT_TYPE' => 'application/json',
);
$client->request('DELETE', "/auth", array(), array(), $headers);
테스트 컨트롤러에서 :
print_r($request->headers);
출력 :
나는Authorization
헤더에 전달할 수있는 방법
Symfony\Component\HttpFoundation\HeaderBag Object
(
[headers:protected] => Array
(
[host] => Array
(
[0] => localhost
)
[user-agent] => Array
(
[0] => Symfony2 BrowserKit
)
[accept] => Array
(
[0] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
)
[accept-language] => Array
(
[0] => en-us,en;q=0.5
)
[accept-charset] => Array
(
[0] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
)
[content-type] => Array
(
[0] => application/json
)
[x-php-ob-level] => Array
(
[0] => 0
)
)
[cacheControl:protected] => Array
(
)
)
?
http://www.php.net/manual/en/reserved.variables.server.php? 내 응용 프로그램이 API 키를 보내고 전달하지 않습니다. –
부하 분산 장치 또는 다른 역방향 프록시를 사용하고 있습니까? – Luke
맞춤 헤더 : http://stackoverflow.com/questions/11549672/symfony-functional-test-custom-headers-not-passing-through –