When I run the server with Example 1 (TinyFastCGI) from the FastCGI documentation (changing the incorrect "SERVER_HOSTNAME" to "SERVER_NAME" in the code), I get the following crash:
$ node node_modules/fastcgi/cli.js --port=8888 --socket=/tmp/tinyfcgi
Sending http requests to /tmp/tinyfcgi
Get FastCGI values
Listening for FastCGI values
FCGI values: {"FCGI_MAX_CONNS":1,"FCGI_MAX_REQS":1,"FCGI_MPXS_CONNS":0}
Listening on 0.0.0.0:8888
Ignoring management record: {"header":{"version":1,"type":10,"recordId":0,"contentLength":0,"paddingLength":0},"body":{},"bodies":[]}
http.js:1140
var statusLine = 'HTTP/1.1 ' + statusCode.toString() + ' ' +
^
TypeError: Cannot call method 'toString' of undefined
at ServerResponse.writeHead (http.js:1140:45)
at send_stdout (/home/roy/Projects/node_modules/fastcgi/fastcgi.js:411:19)
at Parser.on_record [as onRecord] (/home/roy/Projects/node_modules/fastcgi/fastcgi.js:359:14)
at Parser._parser.execute (/home/roy/Projects/node_modules/fastcgi/node_modules/fastcgi-parser/lib/fastcgi.js:242:57)
at FastCGIStream.on_data (/home/roy/Projects/node_modules/fastcgi/fastcgi.js:320:12)
at FastCGIStream.EventEmitter.emit (events.js:95:17)
at FastCGIStream.emit_records (/home/roy/Projects/node_modules/fastcgi/stream.js:181:10)
at FastCGIStream.build_record (/home/roy/Projects/node_modules/fastcgi/stream.js:111:17)
at FastCGIStream.build_record (/home/roy/Projects/node_modules/fastcgi/stream.js:151:8)
at FastCGIStream.build_record (/home/roy/Projects/node_modules/fastcgi/stream.js:151:8)
This happens because the example does not include a Status: 200 header. According to the CGI specification, section 9.2 states:
If the script does not return a Status header, then "200 OK" should be assumed.
The easy workaround is to have the fcgi program return a Status header but it would be best if the fastcgi module (1) properly defaulted the status and (2) did not crash no matter what came over the socket.
When I run the server with Example 1 (TinyFastCGI) from the FastCGI documentation (changing the incorrect "SERVER_HOSTNAME" to "SERVER_NAME" in the code), I get the following crash:
This happens because the example does not include a
Status: 200
header. According to the CGI specification, section 9.2 states:The easy workaround is to have the fcgi program return a
Status
header but it would be best if the fastcgi module (1) properly defaulted the status and (2) did not crash no matter what came over the socket.