Java Code Examples for org.apache.http.HttpStatus#SC_CONTINUE

The following examples show how to use org.apache.http.HttpStatus#SC_CONTINUE . 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: HurlStack.java    From SaveVolley with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if a response message contains a body.
 *
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 */
/*
 * 检查请求结果 Response 是否存在 body
 *
 * 规则是这样的,要 必须 满足 5 点:
 * 1. 请求方法不是 HEAD 方法
 * 2. Status > 100
 * 3. Status < 200
 * 4. Status != 204
 * 5. Status != 304
 *
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD &&
            !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK) &&
            responseCode != HttpStatus.SC_NO_CONTENT &&
            responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 2
Source File: ResponseProtocolCompliance.java    From apigee-android-sdk with Apache License 2.0 6 votes vote down vote up
private void requestDidNotExpect100ContinueButResponseIsOne(
		HttpRequest request, HttpResponse response)
		throws ClientProtocolException {
	if (response.getStatusLine().getStatusCode() != HttpStatus.SC_CONTINUE) {
		return;
	}

	if (!requestWasWrapped(request)) {
		return;
	}

	ProtocolVersion originalProtocol = getOriginalRequestProtocol((RequestWrapper) request);

	if (originalProtocol.compareToVersion(HttpVersion.HTTP_1_1) >= 0) {
		return;
	}

	if (originalRequestDidNotExpectContinue((RequestWrapper) request)) {
		throw new ClientProtocolException(
				"The incoming request did not contain a "
						+ "100-continue header, but the response was a Status 100, continue.");

	}
}
 
Example 3
Source File: HttpRequestHandler.java    From Asqatasun with GNU Affero General Public License v3.0 4 votes vote down vote up
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;
    }
}
 
Example 4
Source File: HurlStack.java    From pearl with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 5
Source File: HurlStack.java    From AndroidProjects with MIT License 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 *
 * @param requestMethod request method
 * @param responseCode  response status code
 * @return whether the response has a body
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
            && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
            && responseCode != HttpStatus.SC_NO_CONTENT
            && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 6
Source File: HurlStack.java    From device-database with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 7
Source File: HurlStack.java    From TitanjumNote with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 8
Source File: HurlStack.java    From product-emm with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 9
Source File: HurlStack.java    From product-emm with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 10
Source File: HurlStack.java    From DaVinci with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 11
Source File: HurlStack.java    From volley_demo with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 12
Source File: HurlStack.java    From jus with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
Example 13
Source File: HurlStack.java    From CrossBow with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}