From ec4070d88edb66cca4e671b6457f499bae93b34f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 13 Jun 2015 22:59:49 -0400 Subject: [PATCH] Send non-chunked response for OPTIONS --- HISTORY.md | 1 + index.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d2e8aa2..cea4006 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ========== + * Send non-chunked response for `OPTIONS` * deps: etag@~1.7.0 - Always include entity length in ETags for hash length extensions - Generate non-Stats ETags using MD5 only (no longer CRC32) diff --git a/index.js b/index.js index 260b3fa..e4d5ac3 100644 --- a/index.js +++ b/index.js @@ -73,9 +73,10 @@ function favicon(path, options) { return; } - if ('GET' !== req.method && 'HEAD' !== req.method) { - var status = 'OPTIONS' === req.method ? 200 : 405; - res.writeHead(status, {'Allow': 'GET, HEAD, OPTIONS'}); + if (req.method !== 'GET' && req.method !== 'HEAD') { + res.statusCode = req.method === 'OPTIONS' ? 200 : 405; + res.setHeader('Allow', 'GET, HEAD, OPTIONS'); + res.setHeader('Content-Length', '0'); res.end(); return; }