diff --git a/test/server.js b/test/server.js index 36d7099..e529f2c 100644 --- a/test/server.js +++ b/test/server.js @@ -41,6 +41,12 @@ TestServer.prototype.router = function(req, res) { res.end('text'); } + if (p === '/options') { + res.statusCode = 200; + res.setHeader('Allow', ['GET', 'HEAD', 'OPTIONS']); + res.end('hello world'); + } + if (p === '/html') { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); diff --git a/test/test.js b/test/test.js index cb3a398..1d98b70 100644 --- a/test/test.js +++ b/test/test.js @@ -607,6 +607,19 @@ describe('node-fetch', function() { }); }); + it('should allow OPTIONS request', function() { + url = base + '/options'; + opts = { + method: 'OPTIONS' + }; + return fetch(url, opts).then(function(res) { + expect(res.status).to.equal(200); + expect(res.statusText).to.equal('OK'); + expect(res.headers.get('allow')).to.equal('GET, HEAD, OPTIONS'); + expect(res.body).to.be.an.instanceof(stream.Transform); + }); + }); + it('should reject decoding body twice', function() { url = base + '/plain'; return fetch(url).then(function(res) {