Java Code Examples for java.net.HttpURLConnection#HTTP_GONE
The following examples show how to use
java.net.HttpURLConnection#HTTP_GONE .
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: ResponseHeaders.java From reader with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 2
Source File: ResponseHeaders.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 3
Source File: ResponseHeaders.java From wildfly-samples with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 4
Source File: ResponseHeaders.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 5
Source File: ResponseHeaders.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 6
Source File: ResponseHeaders.java From phonegapbootcampsite with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 7
Source File: ResponseHeaders.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 8
Source File: ResponseHeaders.java From reader with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 9
Source File: ResponseHeaders.java From bluemix-parking-meter with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 10
Source File: ResponseHeaders.java From android-discourse with Apache License 2.0 | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 11
Source File: ResponseHeaders.java From IoTgo_Android_App with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 12
Source File: ResponseHeaders.java From L.TileLayer.Cordova with MIT License | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 13
Source File: ResponseHeaders.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { // Always go to network for uncacheable response codes (RFC 2616, 13.4), // This implementation doesn't support caching partial content. int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } // Responses to authorized requests aren't cacheable unless they include // a 'public', 'must-revalidate' or 's-maxage' directive. if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 14
Source File: MapDataHistoryDao.java From osmapi with GNU Lesser General Public License v3.0 | 6 votes |
private <T extends Element> T getElementVersion(String call, Class<T> tClass) { SingleOsmElementHandler<T> handler = new SingleOsmElementHandler<>(tClass); try { boolean authenticate = osm.getOAuth() != null; osm.makeRequest(call, authenticate, new MapDataParser(handler, factory)); } catch(OsmApiException e) { /* if a version of an element has been redacted, the api will send back a 403 * forbidden error instead of a 404. Since for the user, this is just a "it's not * there" because he has no way to acquire redacted versions, it should just return * null. The error code between "version does not exist" and "element does not exist" * does not differ, so we cannot make a distinction here */ switch(e.getErrorCode()) { case HttpURLConnection.HTTP_NOT_FOUND: case HttpURLConnection.HTTP_GONE: case HttpURLConnection.HTTP_FORBIDDEN: return null; } throw e; } return handler.get(); }
Example 15
Source File: ResponseHeaders.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Returns true if this response can be stored to later serve another * request. */ public boolean isCacheable(RequestHeaders request) { /* * Always go to network for uncacheable response codes (RFC 2616, 13.4), * This implementation doesn't support caching partial content. */ int responseCode = headers.getResponseCode(); if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) { return false; } /* * Responses to authorized requests aren't cacheable unless they include * a 'public', 'must-revalidate' or 's-maxage' directive. */ if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) { return false; } if (noStore) { return false; } return true; }
Example 16
Source File: OsmApiErrorFactoryTest.java From osmapi with GNU Lesser General Public License v3.0 | 5 votes |
public void testError() { for(int i = 0; i < 600; ++i) { RuntimeException e = OsmApiErrorFactory.createError(i, "test", "description"); if(i >= 400 && i < 500) assertTrue(e instanceof OsmApiException); else assertTrue(e instanceof OsmConnectionException); switch(i) { case HttpURLConnection.HTTP_UNAVAILABLE: assertTrue(e instanceof OsmServiceUnavailableException); break; case HttpURLConnection.HTTP_NOT_FOUND: case HttpURLConnection.HTTP_GONE: assertTrue(e instanceof OsmNotFoundException); break; case HttpURLConnection.HTTP_FORBIDDEN: assertTrue(e instanceof OsmAuthorizationException); break; case HttpURLConnection.HTTP_CONFLICT: assertTrue(e instanceof OsmConflictException); break; case HttpURLConnection.HTTP_BAD_REQUEST: assertTrue(e instanceof OsmBadUserInputException); break; } } }
Example 17
Source File: HttpFileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Determines the type of this file. Must not return null. The return value of this method is cached, so the * implementation can be expensive. */ @Override protected FileType doGetType() throws Exception { // Use the HEAD method to probe the file. final int status = this.getHeadMethod().getStatusCode(); if (status == HttpURLConnection.HTTP_OK || status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) { return FileType.FILE; } else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) { return FileType.IMAGINARY; } else { throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status)); } }
Example 18
Source File: WaitForConditionWatcher.java From kubernetes-client with Apache License 2.0 | 4 votes |
private boolean isHttpGone() { KubernetesClientException cause = ((KubernetesClientException) getCause()); return cause.getCode() == HttpURLConnection.HTTP_GONE || (cause.getStatus() != null && cause.getStatus().getCode() == HttpURLConnection.HTTP_GONE); }
Example 19
Source File: StorageException.java From azure-storage-android with Apache License 2.0 | 4 votes |
/** * Translates the specified HTTP status code into a storage exception. * * @param statusCode * The HTTP status code returned by the operation. * @param statusDescription * A <code>String</code> that represents the status description. * @param inner * An <code>Exception</code> object that represents a reference to the initial exception, if one exists. * * @return A <code>StorageException</code> object that represents translated exception. **/ protected static StorageException translateFromHttpStatus(final int statusCode, final String statusDescription, final Exception inner) { String errorCode; switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: errorCode = StorageErrorCode.ACCESS_DENIED.toString(); break; case HttpURLConnection.HTTP_GONE: case HttpURLConnection.HTTP_NOT_FOUND: errorCode = StorageErrorCode.RESOURCE_NOT_FOUND.toString(); break; case 416: case HttpURLConnection.HTTP_BAD_REQUEST: // 416: RequestedRangeNotSatisfiable - No corresponding enum in HttpURLConnection errorCode = StorageErrorCode.BAD_REQUEST.toString(); break; case HttpURLConnection.HTTP_PRECON_FAILED: case HttpURLConnection.HTTP_NOT_MODIFIED: errorCode = StorageErrorCode.CONDITION_FAILED.toString(); break; case HttpURLConnection.HTTP_CONFLICT: errorCode = StorageErrorCode.RESOURCE_ALREADY_EXISTS.toString(); break; case HttpURLConnection.HTTP_UNAVAILABLE: errorCode = StorageErrorCode.SERVER_BUSY.toString(); break; case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: errorCode = StorageErrorCode.SERVICE_TIMEOUT.toString(); break; case HttpURLConnection.HTTP_INTERNAL_ERROR: errorCode = StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(); break; case HttpURLConnection.HTTP_NOT_IMPLEMENTED: errorCode = StorageErrorCode.NOT_IMPLEMENTED.toString(); break; case HttpURLConnection.HTTP_BAD_GATEWAY: errorCode = StorageErrorCode.BAD_GATEWAY.toString(); break; case HttpURLConnection.HTTP_VERSION: errorCode = StorageErrorCode.HTTP_VERSION_NOT_SUPPORTED.toString(); break; default: errorCode = null; } if (errorCode == null) { return null; } else { return new StorageException(errorCode, statusDescription, statusCode, null, inner); } }
Example 20
Source File: Sentry.java From Sentry-Android with MIT License | 4 votes |
/** * Map from HTTP status code to reason description. * Sentry HTTP breadcrumbs expect a text description of the HTTP status-code. * This function implements a look-up table with a default value for unknown status-codes. * @param statusCode an integer HTTP status code, expected to be in the range [200,505]. * @return a non-empty string in all cases. */ private static String httpReason(int statusCode) { switch (statusCode) { // 2xx case HttpURLConnection.HTTP_OK: return "OK"; case HttpURLConnection.HTTP_CREATED: return "Created"; case HttpURLConnection.HTTP_ACCEPTED: return "Accepted"; case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: return "Non-Authoritative Information"; case HttpURLConnection.HTTP_NO_CONTENT: return "No Content"; case HttpURLConnection.HTTP_RESET: return "Reset Content"; case HttpURLConnection.HTTP_PARTIAL: return "Partial Content"; // 3xx case HttpURLConnection.HTTP_MULT_CHOICE: return "Multiple Choices"; case HttpURLConnection.HTTP_MOVED_PERM: return "Moved Permanently"; case HttpURLConnection.HTTP_MOVED_TEMP: return "Temporary Redirect"; case HttpURLConnection.HTTP_SEE_OTHER: return "See Other"; case HttpURLConnection.HTTP_NOT_MODIFIED: return "Not Modified"; case HttpURLConnection.HTTP_USE_PROXY: return "Use Proxy"; // 4xx case HttpURLConnection.HTTP_BAD_REQUEST: return "Bad Request"; case HttpURLConnection.HTTP_UNAUTHORIZED: return "Unauthorized"; case HttpURLConnection.HTTP_PAYMENT_REQUIRED: return "Payment Required"; case HttpURLConnection.HTTP_FORBIDDEN: return "Forbidden"; case HttpURLConnection.HTTP_NOT_FOUND: return "Not Found"; case HttpURLConnection.HTTP_BAD_METHOD: return "Method Not Allowed"; case HttpURLConnection.HTTP_NOT_ACCEPTABLE: return "Not Acceptable"; case HttpURLConnection.HTTP_PROXY_AUTH: return "Proxy Authentication Required"; case HttpURLConnection.HTTP_CLIENT_TIMEOUT: return "Request Time-Out"; case HttpURLConnection.HTTP_CONFLICT: return "Conflict"; case HttpURLConnection.HTTP_GONE: return "Gone"; case HttpURLConnection.HTTP_LENGTH_REQUIRED: return "Length Required"; case HttpURLConnection.HTTP_PRECON_FAILED: return "Precondition Failed"; case HttpURLConnection.HTTP_ENTITY_TOO_LARGE: return "Request Entity Too Large"; case HttpURLConnection.HTTP_REQ_TOO_LONG: return "Request-URI Too Large"; case HttpURLConnection.HTTP_UNSUPPORTED_TYPE: return "Unsupported Media Type"; // 5xx case HttpURLConnection.HTTP_INTERNAL_ERROR: return "Internal Server Error"; case HttpURLConnection.HTTP_NOT_IMPLEMENTED: return "Not Implemented"; case HttpURLConnection.HTTP_BAD_GATEWAY: return "Bad Gateway"; case HttpURLConnection.HTTP_UNAVAILABLE: return "Service Unavailable"; case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: return "Gateway Timeout"; case HttpURLConnection.HTTP_VERSION: return "Version Not Supported"; default: return "unknown"; } }