Java Code Examples for com.google.api.client.http.HttpResponse#ignore()

The following examples show how to use com.google.api.client.http.HttpResponse#ignore() . 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: HttpResponseUtils.java    From android-oauth-client with Apache License 2.0 5 votes vote down vote up
static boolean hasMessageBody(HttpResponse response) throws IOException {
    int statusCode = response.getStatusCode();
    if (response.getRequest().getRequestMethod().equals(HttpMethods.HEAD)
            || statusCode / 100 == 1
            || statusCode == HttpStatusCodes.STATUS_CODE_NO_CONTENT
            || statusCode == HttpStatusCodes.STATUS_CODE_NOT_MODIFIED) {
        response.ignore();
        return false;
    }
    return true;
}
 
Example 2
Source File: AbstractGoogleClientRequest.java    From google-api-java-client with Apache License 2.0 3 votes vote down vote up
/**
 * Sends the metadata request using HEAD to the server and returns the raw metadata
 * {@link HttpResponse} for the response headers.
 *
 * <p>
 * Only supported when the original request method is GET. The response content is assumed to be
 * empty and ignored. Calls {@link HttpResponse#ignore()} so there is no need to disconnect the
 * response. Example usage:
 * </p>
 *
 * <pre>
   HttpResponse response = request.executeUsingHead();
   // look at response.getHeaders()
 * </pre>
 *
 * <p>
 * Subclasses may override by calling the super implementation.
 * </p>
 *
 * @return the {@link HttpResponse}
 */
protected HttpResponse executeUsingHead() throws IOException {
  Preconditions.checkArgument(uploader == null);
  HttpResponse response = executeUnparsed(true);
  response.ignore();
  return response;
}