
ca.uhn.fhir.rest.client.api.IHttpResponse Maven / Gradle / Ivy
package ca.uhn.fhir.rest.client.api;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2016 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.List;
import java.util.Map;
/**
* An interface around the HTTP Response.
*/
public interface IHttpResponse {
/**
* Get the status code associated with the response.
* @return the response status code.
*/
public int getStatus();
/**
* @return the native response, depending on the client library used
*/
Object getResponse();
/**
* Extracts {@code Content-Type} value from the response exactly as
* specified by the {@code Content-Type} header. Returns {@code null}
* if not specified.
*/
public String getMimeType();
/**
* Get map of the response headers and corresponding string values.
* @return response headers as a map header keys and they values.
*/
public Map> getAllHeaders();
/**
* Get the response status information reason phrase associated with the response.
* @return the reason phrase.
*/
public String getStatusInfo();
/**
* Returna reader for the response entity
*/
public Reader createReader() throws IOException;
/**
* Read the message entity input stream as an InputStream.
*/
public InputStream readEntity() throws IOException;
/**
* Close the response
*/
public void close();
/**
* Buffer the message entity data.
*
* In case the message entity is backed by an unconsumed entity input stream,
* all the bytes of the original entity input stream are read and stored in a
* local buffer. The original entity input stream is consumed.
*
*
* In case the response entity instance is not backed by an unconsumed input stream
* an invocation of {@code bufferEntity} method is ignored and the method returns.
*
*
* This operation is idempotent, i.e. it can be invoked multiple times with
* the same effect which also means that calling the {@code bufferEntity()}
* method on an already buffered (and thus closed) message instance is legal
* and has no further effect.
*
*
* Buffering the message entity data allows for multiple invocations of
* {@code readEntity(...)} methods on the response instance.
*/
void bufferEntitity() throws IOException;
}