diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-01-10 11:12:52 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-01-10 11:13:23 -0800 |
commit | 89afc754d46a8574a9e014c7670746668de9f9b3 (patch) | |
tree | fb4c46b31ac362bb0d8c5a98560cd1865b764615 /src/com/android/providers/downloads/StopRequestException.java | |
parent | 0de55602ec6d350548248feddc68c91b29326eff (diff) | |
download | android_packages_providers_DownloadProvider-89afc754d46a8574a9e014c7670746668de9f9b3.tar.gz android_packages_providers_DownloadProvider-89afc754d46a8574a9e014c7670746668de9f9b3.tar.bz2 android_packages_providers_DownloadProvider-89afc754d46a8574a9e014c7670746668de9f9b3.zip |
Only add one User-Agent header.
Also include more details when reporting HTTP error codes.
Bug: 7966393
Change-Id: I251b1ec7c827693817391b6e9fb8b0cab995395e
Diffstat (limited to 'src/com/android/providers/downloads/StopRequestException.java')
-rw-r--r-- | src/com/android/providers/downloads/StopRequestException.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/com/android/providers/downloads/StopRequestException.java b/src/com/android/providers/downloads/StopRequestException.java index 6df61dce..a2b642d8 100644 --- a/src/com/android/providers/downloads/StopRequestException.java +++ b/src/com/android/providers/downloads/StopRequestException.java @@ -47,14 +47,15 @@ class StopRequestException extends Exception { return mFinalStatus; } - public static StopRequestException throwUnhandledHttpError(int responseCode) + public static StopRequestException throwUnhandledHttpError(int code, String message) throws StopRequestException { - if (responseCode >= 400 && responseCode < 600) { - throw new StopRequestException(responseCode, "Unhandled HTTP response"); - } else if (responseCode >= 300 && responseCode < 400) { - throw new StopRequestException(STATUS_UNHANDLED_REDIRECT, "Unhandled HTTP response"); + final String error = "Unhandled HTTP response: " + code + " " + message; + if (code >= 400 && code < 600) { + throw new StopRequestException(code, error); + } else if (code >= 300 && code < 400) { + throw new StopRequestException(STATUS_UNHANDLED_REDIRECT, error); } else { - throw new StopRequestException(STATUS_UNHANDLED_HTTP_CODE, "Unhandled HTTP response"); + throw new StopRequestException(STATUS_UNHANDLED_HTTP_CODE, error); } } } |