/** * Create a request suitable for use against this service. * * <p> * Subclasses may override by calling the super implementation. * </p> */ public HttpRequest buildHttpRequest() throws IOException { return buildHttpRequest(false); }
/** * Sends the metadata request using the given request method to the server and returns the raw * metadata {@link HttpResponse}. */ private HttpResponse executeUnparsed(boolean usingHead) throws IOException { HttpResponse response; if (uploader == null) { // normal request (not upload) response = buildHttpRequest(usingHead).execute(); } else { // upload request GenericUrl httpRequestUrl = buildHttpRequestUrl(); HttpRequest httpRequest = getAbstractGoogleClient() .getRequestFactory().buildRequest(requestMethod, httpRequestUrl, httpContent); boolean throwExceptionOnExecuteError = httpRequest.getThrowExceptionOnExecuteError(); response = uploader.setInitiationHeaders(requestHeaders) .setDisableGZipContent(disableGZipContent).upload(httpRequestUrl); response.getRequest().setParser(getAbstractGoogleClient().getObjectParser()); // process any error if (throwExceptionOnExecuteError && !response.isSuccessStatusCode()) { throw newExceptionOnError(response); } } // process response lastResponseHeaders = response.getHeaders(); lastStatusCode = response.getStatusCode(); lastStatusMessage = response.getStatusMessage(); return response; }
/** * Create a request suitable for use against this service, but using HEAD instead of GET. * * <p> * Only supported when the original request method is GET. * </p> * * <p> * Subclasses may override by calling the super implementation. * </p> */ protected HttpRequest buildHttpRequestUsingHead() throws IOException { return buildHttpRequest(true); }
/** * Queues the request into the specified batch request container using the specified error class. * * <p> * Batched requests are then executed when {@link BatchRequest#execute()} is called. * </p> * * @param batchRequest batch request container * @param errorClass data class the unsuccessful response will be parsed into or * {@code Void.class} to ignore the content * @param callback batch callback */ public final <E> void queue( BatchRequest batchRequest, Class<E> errorClass, BatchCallback<T, E> callback) throws IOException { Preconditions.checkArgument(uploader == null, "Batching media requests is not supported"); batchRequest.queue(buildHttpRequest(), getResponseClass(), errorClass, callback); }