gnosek / fcgiwrap

Simple FastCGI wrapper for CGI scripts
http://nginx.localdomain.pl/
MIT License
407 stars 134 forks source link

Allow no response headers #62

Open LevitatingBusinessMan opened 5 months ago

LevitatingBusinessMan commented 5 months ago

Currently it isn't possible for a script to not set any response headers.

Fcgiwrap already some work to allow the omission of carriage returns, I slightly altered the statemachine responsible for this to allow for responses with no response headers.

Although response headers are technically required according to rfc3875 it is sometimes omitted.

For instance mod_cgi of lighthttpd will work with just the body: https://github.com/lighttpd/lighttpd1.4/blob/master/src/mod_cgi.c#L631-L639

With this PR a response can now start with a linefeed and then begin it's body.

Additionally I marked cgi_error __noreturn__ as a fix for https://github.com/gnosek/fcgiwrap/issues/57.

fixes https://github.com/gnosek/fcgiwrap/issues/57

gstrauss commented 4 months ago

Although response headers are technically required according to rfc3875 it is sometimes omitted.

FYI: when that occurs, it is frequently someone new to CGI who is unaware of how to write a CGI or FastCGI script.

Providing Status: 200\n\n is sufficient for a 200 OK response, and sending Status is recommended when the body might be empty (where you might send Status: 204\n\n)

If fcgiwrap has long not supported omitting the response header, then there is no backwards compatibility needed and fcgiwrap should continue to reject invalid responses. The reason I added the referenced code to lighttpd mod_cgi to support the case of missing response header was for backwards compatibility.