diff options
author | Steve Howard <showard@google.com> | 2010-07-27 14:34:12 -0700 |
---|---|---|
committer | Steve Howard <showard@google.com> | 2010-07-27 17:15:58 -0700 |
commit | f85aa9ef563f2fbb3c0db6c980121122a14d953f (patch) | |
tree | 4578f5c50db1796ed0679699d9c8cb0e755438c3 /tests | |
parent | f6b4c24b4a876daa3f4e91d6da418983222b9dfd (diff) | |
download | android_packages_providers_DownloadProvider-f85aa9ef563f2fbb3c0db6c980121122a14d953f.tar.gz android_packages_providers_DownloadProvider-f85aa9ef563f2fbb3c0db6c980121122a14d953f.tar.bz2 android_packages_providers_DownloadProvider-f85aa9ef563f2fbb3c0db6c980121122a14d953f.zip |
Improved support for 302/307 redirects.
Change the download manager's handling of 302/307 temporary redirects
so that after an interruption of any kind, the delayed retry/resume
will return to the original URI. This complies better with the HTTP
spec. This change also makes the download manager handle other
redirects immediately rather than using the delay that's otherwise
applied to download errors.
I made one more method extraction in DownloadThread to simplify this
change, pulling the top-level logic for a single request into
executeDownload(). It was then just a matter of introducing a new
RetryDownload exeception, similar to StopRequest, and making the
redirection code use it.
Change-Id: Ic719c5725a9fd2e5eebe4dc03453ee71d9f27cd4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java index b02844fa..c1a015af 100644 --- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java @@ -293,14 +293,13 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { public void testRedirect301() throws Exception { RecordedRequest lastRequest = runRedirectionTest(301); - // for 301, upon retry, we reuse the redirected URI + // for 301, upon retry/resume, we reuse the redirected URI assertEquals(REDIRECTED_PATH, lastRequest.getPath()); } - // TODO: currently fails - public void disabledTestRedirect302() throws Exception { + public void testRedirect302() throws Exception { RecordedRequest lastRequest = runRedirectionTest(302); - // for 302, upon retry, we use the original URI + // for 302, upon retry/resume, we use the original URI assertEquals(REQUEST_PATH, lastRequest.getPath()); } @@ -485,11 +484,8 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { enqueueInterruptedDownloadResponses(5); Download download = enqueueRequest(getRequest()); - download.runUntilStatus(DownloadManager.STATUS_PAUSED); + runService(); assertEquals(REQUEST_PATH, takeRequest().getPath()); - - mSystemFacade.incrementTimeMillis(RETRY_DELAY_MILLIS); - download.runUntilStatus(DownloadManager.STATUS_PAUSED); assertEquals(REDIRECTED_PATH, takeRequest().getPath()); mSystemFacade.incrementTimeMillis(RETRY_DELAY_MILLIS); |