Java Code Examples for com.google.android.vending.expansion.downloader.Constants#MIN_RETRY_AFTER
The following examples show how to use
com.google.android.vending.expansion.downloader.Constants#MIN_RETRY_AFTER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadThread.java From QtAndroidTools with MIT License | 5 votes |
/** * Handle a 503 Service Unavailable status by processing the Retry-After * header. */ private void handleServiceUnavailable(State state, HttpURLConnection connection) throws StopRequest { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP response code 503"); } state.mCountRetry = true; String retryAfterValue = connection.getHeaderField("Retry-After"); if (retryAfterValue != null) { try { if (Constants.LOGVV) { Log.v(Constants.TAG, "Retry-After :" + retryAfterValue); } state.mRetryAfter = Integer.parseInt(retryAfterValue); if (state.mRetryAfter < 0) { state.mRetryAfter = 0; } else { if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) { state.mRetryAfter = Constants.MIN_RETRY_AFTER; } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) { state.mRetryAfter = Constants.MAX_RETRY_AFTER; } state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1); state.mRetryAfter *= 1000; } } catch (NumberFormatException ex) { // ignored - retryAfter stays 0 in this case. } } throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY, "got 503 Service Unavailable, will retry later"); }
Example 2
Source File: DownloadThread.java From play-apk-expansion with Apache License 2.0 | 5 votes |
/** * Handle a 503 Service Unavailable status by processing the Retry-After * header. */ private void handleServiceUnavailable(State state, HttpURLConnection connection) throws StopRequest { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP response code 503"); } state.mCountRetry = true; String retryAfterValue = connection.getHeaderField("Retry-After"); if (retryAfterValue != null) { try { if (Constants.LOGVV) { Log.v(Constants.TAG, "Retry-After :" + retryAfterValue); } state.mRetryAfter = Integer.parseInt(retryAfterValue); if (state.mRetryAfter < 0) { state.mRetryAfter = 0; } else { if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) { state.mRetryAfter = Constants.MIN_RETRY_AFTER; } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) { state.mRetryAfter = Constants.MAX_RETRY_AFTER; } state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1); state.mRetryAfter *= 1000; } } catch (NumberFormatException ex) { // ignored - retryAfter stays 0 in this case. } } throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY, "got 503 Service Unavailable, will retry later"); }
Example 3
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 5 votes |
/** * Handle a 503 Service Unavailable status by processing the Retry-After * header. */ private void handleServiceUnavailable(State state, HttpResponse response) throws StopRequest { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP response code 503"); } state.mCountRetry = true; Header header = response.getFirstHeader("Retry-After"); if (header != null) { try { if (Constants.LOGVV) { Log.v(Constants.TAG, "Retry-After :" + header.getValue()); } state.mRetryAfter = Integer.parseInt(header.getValue()); if (state.mRetryAfter < 0) { state.mRetryAfter = 0; } else { if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) { state.mRetryAfter = Constants.MIN_RETRY_AFTER; } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) { state.mRetryAfter = Constants.MAX_RETRY_AFTER; } state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1); state.mRetryAfter *= 1000; } } catch (NumberFormatException ex) { // ignored - retryAfter stays 0 in this case. } } throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY, "got 503 Service Unavailable, will retry later"); }
Example 4
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 5 votes |
/** * Handle a 503 Service Unavailable status by processing the Retry-After * header. */ private void handleServiceUnavailable(State state, HttpResponse response) throws StopRequest { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP response code 503"); } state.mCountRetry = true; Header header = response.getFirstHeader("Retry-After"); if (header != null) { try { if (Constants.LOGVV) { Log.v(Constants.TAG, "Retry-After :" + header.getValue()); } state.mRetryAfter = Integer.parseInt(header.getValue()); if (state.mRetryAfter < 0) { state.mRetryAfter = 0; } else { if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) { state.mRetryAfter = Constants.MIN_RETRY_AFTER; } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) { state.mRetryAfter = Constants.MAX_RETRY_AFTER; } state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1); state.mRetryAfter *= 1000; } } catch (NumberFormatException ex) { // ignored - retryAfter stays 0 in this case. } } throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY, "got 503 Service Unavailable, will retry later"); }
Example 5
Source File: DownloadThread.java From UnityOBBDownloader with Apache License 2.0 | 5 votes |
/** * Handle a 503 Service Unavailable status by processing the Retry-After * header. */ private void handleServiceUnavailable(State state, HttpURLConnection connection) throws StopRequest { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP response code 503"); } state.mCountRetry = true; String retryAfterValue = connection.getHeaderField("Retry-After"); if (retryAfterValue != null) { try { if (Constants.LOGVV) { Log.v(Constants.TAG, "Retry-After :" + retryAfterValue); } state.mRetryAfter = Integer.parseInt(retryAfterValue); if (state.mRetryAfter < 0) { state.mRetryAfter = 0; } else { if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) { state.mRetryAfter = Constants.MIN_RETRY_AFTER; } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) { state.mRetryAfter = Constants.MAX_RETRY_AFTER; } state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1); state.mRetryAfter *= 1000; } } catch (NumberFormatException ex) { // ignored - retryAfter stays 0 in this case. } } throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY, "got 503 Service Unavailable, will retry later"); }