From f85aa9ef563f2fbb3c0db6c980121122a14d953f Mon Sep 17 00:00:00 2001 From: Steve Howard Date: Tue, 27 Jul 2010 14:34:12 -0700 Subject: 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 --- .../android/providers/downloads/PublicApiFunctionalTest.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/src') 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); -- cgit v1.2.3