Skip to content
Myr

Fix OPTIONS responses to include the HEAD method properly

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fixes #2459

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent fc4eb6d · Browse files · 3 files+23 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−12 removed

  • tests:+8 added−8 removed
  • other:+15 added−4 removed

3 files+23 added−12 removed

modified:lib/router/route.js+14 added-4 removed
modified:test/app.options.js+8 added-8 removed
10 unmodified lines
11 app.put('/users', function(req, res){});1213 request(app)14 .options('/users')15 .expect('GET,PUT')16 .expect('Allow', 'GET,PUT', done);15 .expect('Allow', 'GET,HEAD,PUT')16 .expect(200, 'GET,HEAD,PUT', done);17 })1819 it('should only include each method once', function(done){20 var app = express();
4 unmodified lines
25 app.get('/users', function(req, res){});2627 request(app)28 .options('/users')29 .expect('GET,PUT')30 .expect('Allow', 'GET,PUT', done);29 .expect('Allow', 'GET,HEAD,PUT')30 .expect(200, 'GET,HEAD,PUT', done);31 })3233 it('should not be affected by app.all', function(done){34 var app = express();
8 unmodified lines
4344 request(app)45 .options('/users')46 .expect('x-hit', '1')47 .expect('allow', 'GET,PUT')48 .expect(200, 'GET,PUT', done);47 .expect('Allow', 'GET,HEAD,PUT')48 .expect(200, 'GET,HEAD,PUT', done);49 })5051 it('should not respond if the path is not defined', function(done){52 var app = express();
14 unmodified lines
67 app.get('/other', function(req, res){});6869 request(app)70 .options('/other')71 .expect('GET')72 .expect('Allow', 'GET', done);71 .expect('Allow', 'GET,HEAD')72 .expect(200, 'GET,HEAD', done);73 })7475 describe('when error occurs in respone handler', function () {76 it('should pass error to callback', function (done) {
39 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * Deprecate leading `:` in `name` for `app.param(name, fn)`5 * Fix `OPTIONS` responses to include the `HEAD` method properly674.10.8 / 2015-01-138===================9
2546 unmodified lines