Merge branch 'master' of https://github.com/jpuerto/cordova-mobile-spec
diff --git a/www/file/index.html b/www/file/index.html
index 8f00e86..11f7997 100644
--- a/www/file/index.html
+++ b/www/file/index.html
@@ -39,6 +39,7 @@
<div class="btn large" id="downloadImgNative">Download and display img (native)</div>
<div class="btn large" id="downloadVideoCDV">Download and play video (cdvfile)</div>
<div class="btn large" id="downloadVideoNative">Download and play video (native)</div>
+ <div class="btn large" id="testNotModified">Handle 304 status code</div>
<div class="ios platform">
<h2>iOS Special URL handling</h2>
diff --git a/www/file/index.js b/www/file/index.js
index 1f570dd..97b0d96 100644
--- a/www/file/index.js
+++ b/www/file/index.js
@@ -26,6 +26,7 @@
document.getElementById('downloadVideoCDV').addEventListener('click', downloadVideoCDV, false);
document.getElementById('downloadVideoNative').addEventListener('click', downloadVideoNative, false);
document.getElementById('testPrivateURL').addEventListener('click', testPrivateURL, false);
+ document.getElementById('testNotModified').addEventListener('click', testNotModified, false);
var fsButtons = document.querySelectorAll('.resolveFs');
for (var i=0; i < fsButtons.length; ++i) {
fsButtons[i].addEventListener('click', resolveFs, false);
@@ -81,6 +82,25 @@
downloadImg(videoURL, function(entry) { return entry.toNativeURL(); }, videoElement);
}
+function testNotModified(ev) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ var ft = new FileTransfer();
+ var lastModified = new Date();
+ var headers = { "If-Modified-Since": lastModified.toUTCString()};
+ logMessage("Starting cached download with headers: " + JSON.stringify(headers));
+ ft.download(imageURL, "", function() {
+ logError("ft.download");
+ }, function (error) {
+ if (error.code === 5) {
+ logMessage("Success, the file was not modified.", "green");
+ } else {
+ logError("ft.download");
+ }
+
+ }, false, {headers: headers});
+}
+
function downloadImg(source, urlFn, element) {
var filename = source.substring(source.lastIndexOf("/")+1);
function download(fileSystem) {