You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2012/01/07 17:01:54 UTC
git commit: Cache-bust every attachment range GET
Updated Branches:
refs/heads/master 07c78bf41 -> 6f774bc0e
Cache-bust every attachment range GET
This appears to expose a bug in Chrome for an edge case. There's a
test that sends "Range: bytes=0-29" for an item that is one byte
shorter than the requested range. Curl, Firefox and Safari correctly
returns;
Content-Range: bytes 0-28/29
Content-Length: 29
Whereas Safari erroneously gets this;
Content-Range: bytes 0-29/29
Content-Length: 30
So, this test will fail on Chrome until a) Chrome is fixed or b)
someone points out that I'm wrong about the Chrome bug.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6f774bc0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6f774bc0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6f774bc0
Branch: refs/heads/master
Commit: 6f774bc0e73fbd805384acbb98c9a89d84793f8e
Parents: 07c78bf
Author: Robert Newson <rn...@apache.org>
Authored: Sat Jan 7 15:57:04 2012 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Sat Jan 7 15:57:04 2012 +0000
----------------------------------------------------------------------
share/www/script/test/attachment_ranges.js | 30 +++++++++++++----------
1 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6f774bc0/share/www/script/test/attachment_ranges.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/attachment_ranges.js b/share/www/script/test/attachment_ranges.js
index 603848e..a4ea4d3 100644
--- a/share/www/script/test/attachment_ranges.js
+++ b/share/www/script/test/attachment_ranges.js
@@ -9,6 +9,11 @@
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
+
+function cacheBust() {
+ return "?anti-cache=" + String(Math.round(Math.random() * 1000000));
+};
+
couchTests.attachment_ranges = function(debug) {
var db = new CouchDB("test_suite_db", {
"X-Couch-Full-Commit": "false"
@@ -32,7 +37,7 @@ couchTests.attachment_ranges = function(debug) {
T(save_response.ok);
// Fetching the whole entity is a 206.
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt?bar=0", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-28"
}
@@ -43,8 +48,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("29", xhr.getResponseHeader("Content-Length"));
// Fetch the whole entity without an end offset is a 200.
- var rand = "&foo=" + Math.random(10000000);
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt?bar=1" + rand, {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-"
}
@@ -55,7 +59,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("29", xhr.getResponseHeader("Content-Length"));
// Even if you ask multiple times.
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-,0-,0-"
}
@@ -63,7 +67,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals(200, xhr.status, "multiple 0-'s");
// Badly formed range header is a 200.
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes:0-"
}
@@ -71,7 +75,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals(200, xhr.status, "fetch with bad range header");
// 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", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=2-"
}
@@ -82,7 +86,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("27", xhr.getResponseHeader("Content-Length"));
// Fetch past the end of the entity is a 206
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-29"
}
@@ -92,7 +96,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("29", xhr.getResponseHeader("Content-Length"));
// Fetch first part of entity is a 206
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-3"
}
@@ -103,7 +107,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("bytes 0-3/29", xhr.getResponseHeader("Content-Range"));
// Fetch middle of entity is also a 206
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=10-15"
}
@@ -114,7 +118,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("bytes 10-15/29", xhr.getResponseHeader("Content-Range"));
// Fetch end of entity is also a 206
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=-3"
}
@@ -125,7 +129,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals("bytes 26-28/29", xhr.getResponseHeader("Content-Range"));
// backward range is 416
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=5-3"
}
@@ -133,7 +137,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals(416, xhr.status, "fetch 5-3");
// range completely outside of entity is 416
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=300-310"
}
@@ -141,7 +145,7 @@ couchTests.attachment_ranges = function(debug) {
TEquals(416, xhr.status, "fetch 300-310");
// We ignore a Range header with too many ranges
- var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt", {
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt" + cacheBust(), {
headers: {
"Range": "bytes=0-1,0-1,0-1,0-1,0-1,0-1,0-1,0-1,0-1,0-1"
}