Permalink
Browse files

Fix for http://github.com/mde/geddy/issues#issue/32 -- some clients d…

…on't provide an Accept header.
  • Loading branch information...
1 parent 5cf63d8 commit cc7d44e981e6b482dc441cbf32252df82f6a24f4 mde committed Aug 21, 2010
Showing with 15 additions and 1 deletion.
  1. +15 −1 geddy-core/lib/controller.js
@@ -83,8 +83,13 @@ Controller.prototype = new function () {
this[phase + 'Filters'].push(obj);
}
+ /**
+ * Primary entry point for calling the action on a controller
+ */
this.handleAction = function (action, params) {
var _this = this;
+ // Wrap the actual action-handling in a callback to use as the 'last'
+ // method in the async chain of before-filters
var callback = function () {
_this[action].call(_this, params);
};
@@ -218,10 +223,19 @@ Controller.prototype = new function () {
, match
, params = this.params
, err
- , accepts = this.request.headers.accept.split(',')
+ , accepts = this.request.headers.accept
, pat
, wildcard = false;
+ // If the client doesn't provide an Accept header, assume
+ // it's happy with anything
+ if (accepts) {
+ accepts = accepts.split(',');
+ }
+ else {
+ accepts = ['*/*'];
+ }
+
if (frmt) {
types = [frmt];
}

0 comments on commit cc7d44e

Please sign in to comment.