/** * Sends the metadata request to the server and returns the raw metadata {@link HttpResponse}. * * <p> * Callers are responsible for disconnecting the HTTP response by calling * {@link HttpResponse#disconnect}. Example usage: * </p> * * <pre> HttpResponse response = request.executeUnparsed(); try { // process response.. } finally { response.disconnect(); } * </pre> * * <p> * Subclasses may override by calling the super implementation. * </p> * * @return the {@link HttpResponse} */ public HttpResponse executeUnparsed() throws IOException { return executeUnparsed(false); }
/** * Sends the metadata request to the server and returns the parsed metadata response. * * <p> * Subclasses may override by calling the super implementation. * </p> * * @return parsed HTTP response */ public T execute() throws IOException { return executeUnparsed().parseAs(responseClass); }
/** * Sends the metadata request to the server and writes the metadata content input stream of * {@link HttpResponse} into the given destination output stream. * * <p> * This method closes the content of the HTTP response from {@link HttpResponse#getContent()}. * </p> * * <p> * Subclasses may override by calling the super implementation. * </p> * * @param outputStream destination output stream */ public void executeAndDownloadTo(OutputStream outputStream) throws IOException { executeUnparsed().download(outputStream); }
/** * Sends the metadata request to the server and returns the metadata content input stream of * {@link HttpResponse}. * * <p> * Callers are responsible for closing the input stream after it is processed. Example sample: * </p> * * <pre> InputStream is = request.executeAsInputStream(); try { // Process input stream.. } finally { is.close(); } * </pre> * * <p> * Subclasses may override by calling the super implementation. * </p> * * @return input stream of the response content */ public InputStream executeAsInputStream() throws IOException { return executeUnparsed().getContent(); }
/** * Sends the media request to the server and returns the raw media {@link HttpResponse}. * * <p> * Callers are responsible for disconnecting the HTTP response by calling * {@link HttpResponse#disconnect}. Example usage: * </p> * * <pre> HttpResponse response = request.executeMedia(); try { // process response.. } finally { response.disconnect(); } * </pre> * * <p> * Subclasses may override by calling the super implementation. * </p> * * @return the {@link HttpResponse} */ protected HttpResponse executeMedia() throws IOException { set("alt", "media"); return executeUnparsed(); }
/** * 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; }