Changing HTTP status from FastCGI

Igor Sysoev igor at sysoev.ru
Fri Sep 17 00:05:52 MSD 2010


On Wed, Sep 15, 2010 at 08:23:31PM -0400, tdebber wrote:

> Hello,
> 
> I am trying to change the HTTP status that is sent when I send a
> response to a FastCGI query.  In the nginx configuration file, I have 
> 
> fastcgi_pass_header Status;

You should not pass Status header line.

> When generating my return stream, which is done in C++, the first part
> of response is:
> "Status: 201\r\n"
> I have also tried:
> "Status: 201 Created\r\n"
> as well as different combinations of \n and \r\n following the header. 
> In all cases, HTTP/1.1 200 OK is set as the Status and the body of the
> response contains the string I've tried to use as my header.  Any hints
> as to what I may be doing wrong?

You should seperate response header and body using additional "\r\n":
----
Status: 201
Content-Type: text/html

some body text
----

If you send only Status without other headers, you need to change:

- "Status: 201\r\n"
+ "Status: 201\r\n\r\n\"


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list