Java Code Examples for org.apache.http.HttpStatus#SC_REQUESTED_RANGE_NOT_SATISFIABLE
The following examples show how to use
org.apache.http.HttpStatus#SC_REQUESTED_RANGE_NOT_SATISFIABLE .
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: RangeFileAsyncHttpResponseHandler.java From Mobike with Apache License 2.0 | 6 votes |
@Override public void sendResponseMessage(HttpResponse response) throws IOException { if (!Thread.currentThread().isInterrupted()) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { //already finished if (!Thread.currentThread().isInterrupted()) sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null); } else if (status.getStatusCode() >= 300) { if (!Thread.currentThread().isInterrupted()) sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase())); } else { if (!Thread.currentThread().isInterrupted()) { Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE); if (header == null) { append = false; current = 0; } else { Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue()); } sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity())); } } } }
Example 2
Source File: RangeFileAsyncHttpResponseHandler.java From android-project-wo2b with Apache License 2.0 | 6 votes |
@Override public void sendResponseMessage(HttpResponse response) throws IOException { if (!Thread.currentThread().isInterrupted()) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { //already finished if (!Thread.currentThread().isInterrupted()) sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null); } else if (status.getStatusCode() >= 300) { if (!Thread.currentThread().isInterrupted()) sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase())); } else { if (!Thread.currentThread().isInterrupted()) { Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE); if (header == null) { append = false; current = 0; } else Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue()); sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity())); } } } }
Example 3
Source File: RangeFileAsyncHttpResponseHandler.java From Android-Basics-Codes with Artistic License 2.0 | 6 votes |
@Override public void sendResponseMessage(HttpResponse response) throws IOException { if (!Thread.currentThread().isInterrupted()) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { //already finished if (!Thread.currentThread().isInterrupted()) sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null); } else if (status.getStatusCode() >= 300) { if (!Thread.currentThread().isInterrupted()) sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase())); } else { if (!Thread.currentThread().isInterrupted()) { Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE); if (header == null) { append = false; current = 0; } else { Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue()); } sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity())); } } } }
Example 4
Source File: RangeFileAsyncHttpResponseHandler.java From Android-Basics-Codes with Artistic License 2.0 | 6 votes |
@Override public void sendResponseMessage(HttpResponse response) throws IOException { if (!Thread.currentThread().isInterrupted()) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { //already finished if (!Thread.currentThread().isInterrupted()) sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null); } else if (status.getStatusCode() >= 300) { if (!Thread.currentThread().isInterrupted()) sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase())); } else { if (!Thread.currentThread().isInterrupted()) { Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE); if (header == null) { append = false; current = 0; } else { Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue()); } sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity())); } } } }
Example 5
Source File: RangeFileAsyncHttpResponseHandler.java From Android-Basics-Codes with Artistic License 2.0 | 6 votes |
@Override public void sendResponseMessage(HttpResponse response) throws IOException { if (!Thread.currentThread().isInterrupted()) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { //already finished if (!Thread.currentThread().isInterrupted()) sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null); } else if (status.getStatusCode() >= 300) { if (!Thread.currentThread().isInterrupted()) sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase())); } else { if (!Thread.currentThread().isInterrupted()) { Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE); if (header == null) { append = false; current = 0; } else { Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue()); } sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity())); } } } }
Example 6
Source File: ExtendedS3Storage.java From pravega with Apache License 2.0 | 5 votes |
private <T> T throwException(String segmentName, Exception e) throws StreamSegmentException { if (e instanceof S3Exception) { S3Exception s3Exception = (S3Exception) e; String errorCode = Strings.nullToEmpty(s3Exception.getErrorCode()); if (errorCode.equals("NoSuchKey")) { throw new StreamSegmentNotExistsException(segmentName); } if (errorCode.equals("PreconditionFailed")) { throw new StreamSegmentExistsException(segmentName); } if (errorCode.equals("InvalidRange") || errorCode.equals("InvalidArgument") || errorCode.equals("MethodNotAllowed") || s3Exception.getHttpCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { throw new IllegalArgumentException(segmentName, e); } if (errorCode.equals("AccessDenied")) { throw new StreamSegmentSealedException(segmentName, e); } } if (e instanceof IndexOutOfBoundsException) { throw new ArrayIndexOutOfBoundsException(e.getMessage()); } throw Exceptions.sneakyThrow(e); }
Example 7
Source File: HttpResponseExceptionMappingService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
public BackgroundException map(final Throwable failure, final StringBuilder buffer, final int statusCode) { switch(statusCode) { case HttpStatus.SC_UNAUTHORIZED: return new LoginFailureException(buffer.toString(), failure); case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: return new ProxyLoginFailureException(buffer.toString(), failure); case HttpStatus.SC_FORBIDDEN: case HttpStatus.SC_NOT_ACCEPTABLE: return new AccessDeniedException(buffer.toString(), failure); case HttpStatus.SC_CONFLICT: return new ConflictException(buffer.toString(), failure); case HttpStatus.SC_NOT_FOUND: case HttpStatus.SC_GONE: case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE: return new NotfoundException(buffer.toString(), failure); case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE: case HttpStatus.SC_INSUFFICIENT_STORAGE: case HttpStatus.SC_PAYMENT_REQUIRED: return new QuotaException(buffer.toString(), failure); case HttpStatus.SC_UNPROCESSABLE_ENTITY: case HttpStatus.SC_BAD_REQUEST: case HttpStatus.SC_REQUEST_URI_TOO_LONG: case HttpStatus.SC_METHOD_NOT_ALLOWED: case HttpStatus.SC_NOT_IMPLEMENTED: return new InteroperabilityException(buffer.toString(), failure); case HttpStatus.SC_REQUEST_TIMEOUT: case HttpStatus.SC_GATEWAY_TIMEOUT: return new ConnectionTimeoutException(buffer.toString(), failure); case HttpStatus.SC_LOCKED: return new LockedException(buffer.toString(), failure); case HttpStatus.SC_BAD_GATEWAY: case HttpStatus.SC_INTERNAL_SERVER_ERROR: case HttpStatus.SC_SERVICE_UNAVAILABLE: case 429: // Too Many Requests. Rate limiting case 509: // Bandwidth Limit Exceeded return new RetriableAccessDeniedException(buffer.toString(), failure); default: return new InteroperabilityException(buffer.toString(), failure); } }
Example 8
Source File: HttpRequestHandler.java From Asqatasun with GNU Affero General Public License v3.0 | 4 votes |
private int computeStatus(int status) { switch (status) { case HttpStatus.SC_FORBIDDEN: case HttpStatus.SC_METHOD_NOT_ALLOWED: case HttpStatus.SC_BAD_REQUEST: case HttpStatus.SC_UNAUTHORIZED: case HttpStatus.SC_PAYMENT_REQUIRED: case HttpStatus.SC_NOT_FOUND: case HttpStatus.SC_NOT_ACCEPTABLE: case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: case HttpStatus.SC_REQUEST_TIMEOUT: case HttpStatus.SC_CONFLICT: case HttpStatus.SC_GONE: case HttpStatus.SC_LENGTH_REQUIRED: case HttpStatus.SC_PRECONDITION_FAILED: case HttpStatus.SC_REQUEST_TOO_LONG: case HttpStatus.SC_REQUEST_URI_TOO_LONG: case HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE: case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE: case HttpStatus.SC_EXPECTATION_FAILED: case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE: case HttpStatus.SC_METHOD_FAILURE: case HttpStatus.SC_UNPROCESSABLE_ENTITY: case HttpStatus.SC_LOCKED: case HttpStatus.SC_FAILED_DEPENDENCY: case HttpStatus.SC_INTERNAL_SERVER_ERROR: case HttpStatus.SC_NOT_IMPLEMENTED: case HttpStatus.SC_BAD_GATEWAY: case HttpStatus.SC_SERVICE_UNAVAILABLE: case HttpStatus.SC_GATEWAY_TIMEOUT: case HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED: case HttpStatus.SC_INSUFFICIENT_STORAGE: return 0; case HttpStatus.SC_CONTINUE: case HttpStatus.SC_SWITCHING_PROTOCOLS: case HttpStatus.SC_PROCESSING: case HttpStatus.SC_OK: case HttpStatus.SC_CREATED: case HttpStatus.SC_ACCEPTED: case HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION: case HttpStatus.SC_NO_CONTENT: case HttpStatus.SC_RESET_CONTENT: case HttpStatus.SC_PARTIAL_CONTENT: case HttpStatus.SC_MULTI_STATUS: case HttpStatus.SC_MULTIPLE_CHOICES: case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_SEE_OTHER: case HttpStatus.SC_NOT_MODIFIED: case HttpStatus.SC_USE_PROXY: case HttpStatus.SC_TEMPORARY_REDIRECT: return 1; default : return 1; } }