Skip to content
Myr

Fix crash from error within OPTIONS response handler

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

fixes #2494

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 4070dab · Browse files · 3 files+35 added−3 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+35 added−3 removed

  • tests:+22 added−0 removed
  • other:+13 added−3 removed

3 files+35 added−3 removed

modified:lib/router/index.js+12 added-3 removed
150 unmodified lines
151 // for options requests, respond with a default if nothing else responds152 if (req.method === 'OPTIONS') {153 done = wrap(done, function(old, err) {154 if (err || options.length === 0) return old(err);155156 var body = options.join(',');157 return res.set('Allow', body).send(body);155 sendOptionsResponse(res, options, old);156 });157 }158159 // setup basic req values
408 unmodified lines
568 return fn.apply(this, arguments);569 };570}571572// send an OPTIONS response573function sendOptionsResponse(res, options, next) {574 try {575 var body = options.join(',');576 res.set('Allow', body);577 res.send(body);578 } catch (err) {579 next(err);580 }581}582583// wrap a function584function wrap(old, fn) {585 return function proxy() {586 var args = new Array(arguments.length + 1);
9 unmodified lines
modified:test/app.options.js+22 added
modified:History.md+1 added
1unreleased2==========34 * Fix crash from error within `OPTIONS` response handler5 * deps: proxy-addr@~1.0.56 - deps: ipaddr.js@0.1.6784.10.7 / 2015-01-04
2541 unmodified lines