Changing HTTP status from FastCGI

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;

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?

Thank you,
Matt Debski

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,130798,130798#msg-130798

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 S.
http://sysoev.ru/en/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs