public class FcrepoResponse extends Object implements Closeable
FcrepoClient.
This class implements Closeable. Suggested usage is to create the FcrepoResponse within a
try-with-resources block, insuring that any resources held by the response are freed automatically.
FcrepoClient client = ...;
try (FcrepoResponse res = client.get(...)) {
// do something with the response
} catch (FcrepoOperationFailedException|IOException e) {
// handle any exceptions
}
Closed responses have no obligation to provide access to released resources.| Constructor and Description |
|---|
FcrepoResponse(URI url,
int statusCode,
Map<String,List<String>> headers,
InputStream body)
Create a FcrepoResponse object from the http response
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
InputStream |
getBody()
body getter
|
Map<String,String> |
getContentDisposition()
Get a map of parameters from the Content-Disposition header if present
|
String |
getContentType()
contentType getter
|
Map<String,List<String>> |
getHeaders()
headers getter
|
String |
getHeaderValue(String name)
Get the first value for the specified header
|
List<String> |
getHeaderValues(String name)
Get all values for the specified header
|
List<URI> |
getLinkHeaders(String relationship)
Retrieve link header values matching the given relationship
|
URI |
getLocation()
location getter
|
int |
getStatusCode()
statusCode getter
|
URI |
getUrl()
url getter
|
boolean |
isClosed()
Whether or not the resources have been freed from this response.
|
void |
setBody(InputStream body)
body setter
|
void |
setContentType(String contentType)
contentType setter
|
void |
setHeaders(Map<String,List<String>> headers)
headers setter
|
void |
setLocation(URI location)
location setter
|
void |
setStatusCode(int statusCode)
statusCode setter
|
void |
setUrl(URI url)
url setter
|
public FcrepoResponse(URI url, int statusCode, Map<String,List<String>> headers, InputStream body)
url - the requested URLstatusCode - the HTTP status codeheaders - a map of all response header names and valuesbody - the response body streampublic void close() throws IOException
Implementation note: Invoking this method will close the underlying InputStream containing the entity
body of the HTTP response.
close in interface Closeableclose in interface AutoCloseableIOException - if there is an error closing the underlying HTTP response stream.public boolean isClosed()
entity body.true if resources have been freed, otherwise falsepublic int getStatusCode()
public void setStatusCode(int statusCode)
statusCode - the HTTP status codepublic InputStream getBody()
public void setBody(InputStream body)
body - the contents of the response bodypublic Map<String,List<String>> getHeaders()
public List<String> getHeaderValues(String name)
name - name of the header to retrievepublic String getHeaderValue(String name)
name - name of the header to retrievepublic void setHeaders(Map<String,List<String>> headers)
headers - headers from the responsepublic List<URI> getLinkHeaders(String relationship)
relationship - the relationship of links to returnpublic URI getLocation()
public void setLocation(URI location)
location - the value of a related resourcepublic String getContentType()
public void setContentType(String contentType)
contentType - the mime-type of the responsepublic Map<String,String> getContentDisposition()
Copyright © 2013-2016 DuraSpace, Inc.. All Rights Reserved.