summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2010-08-24 09:43:47 +0000
committerRobert Newson <rnewson@apache.org>2010-08-24 09:43:47 +0000
commit3c985840f1b394ca9ec43412d086ea9ca6cd1ddb (patch)
tree073e5e122acdc74e6bcc9b2bc674963e7943ee3f
parent9d1fe2f440b95ab75089fab077e880c3d8425ff6 (diff)
return 400 Bad Request for unparseable range request.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@988450 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/test/attachment_ranges.js8
-rw-r--r--src/couchdb/couch_httpd_db.erl2
2 files changed, 10 insertions, 0 deletions
diff --git a/share/www/script/test/attachment_ranges.js b/share/www/script/test/attachment_ranges.js
index 65c1f475..aa5edd38 100644
--- a/share/www/script/test/attachment_ranges.js
+++ b/share/www/script/test/attachment_ranges.js
@@ -52,6 +52,14 @@ couchTests.attachment_ranges = function(debug) {
TEquals("This is a base64 encoded text", xhr.responseText);
TEquals("29", xhr.getResponseHeader("Content-Length"));
+ // Badly formed range header is a 400.
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ headers: {
+ "Range": "bytes:0-"
+ }
+ });
+ TEquals(400, xhr.status);
+
// Fetch the end of an entity without an end offset is a 206.
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
headers: {
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 062cf320..17b27b13 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -1059,6 +1059,8 @@ db_attachment_req(Req, _Db, _DocId, _FileNameParts) ->
parse_ranges(undefined, Len) ->
undefined;
+parse_ranges(fail, Len) ->
+ throw(bad_request);
parse_ranges(Ranges, Len) ->
parse_ranges(Ranges, Len, []).