php头位置在php fpm和nginx为200时自动将http_response_code设置为302


php header location auto set http_response_code to 302 when it is 200 with php-fpm and nginx?

类似代码:

<?php
header('Location: http://www.google.com', TRUE, 200);

在apache+php中运行时,httpresponse_code为200,但在nginx+php-fpm中运行时则为302。

nginx+php-fpm中会发生什么?

在阅读nginx的源代码后,我发现在/src/http/modules/ngx_http_fastcgi_module.c的第1564行,有一些关于将状态代码设置为302的代码。

header('Location: http://www.google.com', TRUE, 200);

fpm不会将响应代码200传递给nginx,因此响应代码将设置为302