Permalink
Browse files

checking for null keys from key generation function

  • Loading branch information...
1 parent 94b4880 commit 4b5e066a3cc375feb691030f9ea90886970d376c Josh Devins committed Nov 21, 2010
Showing with 7 additions and 4 deletions.
  1. +0 −1 README.md
  2. +2 −2 config.js
  3. +5 −1 node-rate-limiter-proxy.js
View
@@ -56,7 +56,6 @@ TODO
---
* better Redis failure handling
- * check for null keys from key generate function
* HTTPS support
* ensure race condition goes away between TTL expiry check and reset (upstream server can get stampeded)
* optimistic locking in Redis (requires Redis 2.1.0)
View
@@ -12,11 +12,11 @@ var config = {
periodInSeconds: 60,
statusPath: '/status/', // must start and end with forward slashes
buildKeyFunction: function(request) {
-
+
if (request.headers.authorization == null) {
return '';
}
-
+
return request.headers.authorization.split(' ')[1];
}
};
@@ -221,9 +221,13 @@ function serverCallback(request, response) {
}
// get key from a configurable function
- // TODO: Check for null keys?
var key = config.buildKeyFunction(request);
+ if (key == null) {
+ sys.log("Null key returned from buildKeyFunction in config!");
+ throw "NullKeyException";
+ }
+
if (request.headers['x-ratelimit-status'] != null) {
getStatusAndRespond(request, response, key);
return;

0 comments on commit 4b5e066

Please sign in to comment.