12345678910111213141516171819202122232425262728293031323334 |
- const ACCEPTABLE_CONTENT_TYPE = /^(multipart\/.+);(.*)$/i;
- const UNACCEPTABLE_METHODS = ['GET', 'HEAD'];
- const hasBody = (req) => {
- return ('transfer-encoding' in req.headers) ||
- ('content-length' in req.headers && req.headers['content-length'] !== '0');
- };
- const hasAcceptableMethod = req => !UNACCEPTABLE_METHODS.includes(req.method);
- const hasAcceptableContentType = req => ACCEPTABLE_CONTENT_TYPE.test(req.headers['content-type']);
- module.exports = req => hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req);
|