pico-engine
pico-engine copied to clipboard
The HTTP headers passed into rule and function seem to be incomplete
We've gotten along without this for some time, but when using a pico to host a web application it would be useful to know some more things about the HTTP requests coming in. For instance, what is the HTTP method (GET or POST, etc.)?
Hm. The code doesn't do anything to remove anything from the headers provided by express
, which are quite slim compared to those provided by the Common Gateway Interface (CGI). Generate a current list from my status.pl CGI script (which shows a REQUEST_METHOD
header among many other CGI headers).
Turns out that express
does provide the information, in req.method
which could be added to the _headers
map.
A request_method
header can be added by changing this line
return _.assign({}, req.query, req.body, { _headers: req.headers });
to look like this line
return _.assign({}, req.query, req.body, { _headers: _.assign(req.headers, { request_method: req.method }) });