Created
May 3, 2010 20:25
-
-
Save dvv/388542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- rest-store.js.orig 2010-05-04 18:59:11.000000000 +0400 | |
+++ rest-store.js 2010-05-04 01:08:07.000000000 +0400 | |
@@ -63,19 +63,19 @@ | |
else if(!METHOD_HAS_BODY[method]){ | |
if(method === "get" && request.pathInfo.substring(request.pathInfo.length - 1) === "/"){ | |
// handle the range header | |
- if(metadata.range){ | |
- // invalid "Range:" just results in 0-Infinity | |
+ if (metadata.range) { | |
+ // invalid "Range:" are ignored | |
+ var r = false; | |
metadata.range.replace(/^items=(\d+)-(\d+)?/, function(s, b, e){ | |
- if(b >= 0){ | |
- metadata.start = b; | |
- } | |
- if(e >= b){ | |
- metadata.end = e; | |
- } | |
- else if (e !== undefined){ | |
+ metadata.start = +b; | |
+ if (+e >= b) { | |
+ metadata.end = +e; | |
+ r = true; | |
+ } else if (e !== undefined) { | |
delete metadata.start; | |
} | |
}); | |
+ if (!r) delete metadata.range; | |
} | |
// queries are not decoded, the info needs to be retained for parsing | |
// TODO: limit the range by a configurable number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment