com.univocity.api.net
Interface HttpResponse

All Superinterfaces:
Closeable

public interface HttpResponse
extends Closeable

A response object resulting from a HTTP request (HttpRequest) invoked from the UrlReaderProvider. Both text and binary content are supported.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
HttpResponseReader, HttpRequest, RequestMethod, UrlReaderProvider

Method Summary
 void close()
          Closes any resources associated with reading the request response content.
 String getCharset()
          The character set from the Content-Type header, or if explicitly provided in the HTTP request, the result of HttpRequest.getCharsetName().
 String getContent()
          Returns a String with the content of the response body of this HTTP response.
 long getContentLength()
          Returns the length of the content in the body of this HTTP response, as specified in the {code Content-Length} header.
 Reader getContentReader()
          Returns a Reader instance to be used to read the content of the response body of this HTTP response.
 String getContentType()
          Returns the value of the Content-Type header which indicates the format of the content sent in response to the HTTP request.
 Map<String,String> getCookies()
          Returns a map with the cookie collection listed in the Set-Cookie header of this response message.
 Map<String,String> getHeaders()
          Returns the headers and their corresponding values in this HTTP response.
 Map<String,List<String>> getMultiHeaders()
          Returns the headers and their corresponding values in this HTTP response.
 String getRedirectionUrl()
          Gets the redirection URL if the request has been redirected and HttpRequest.getFollowRedirects() evaluates to true
 int getRetriesPerformed()
          Returns the number of retries performed by the UrlReaderProvider until a response was obtained.
 int getStatusCode()
          Returns the integer HTTP response status code.
 String getStatusMessage()
          Returns the HTTP response status message
 URL getUrl()
          The URL object used to produce this HttpResponse
 void readContent(HttpResponseReader responseReader)
          Reads this HTTP response using a custom class (i.e.
 

Method Detail

getRedirectionUrl

String getRedirectionUrl()
Gets the redirection URL if the request has been redirected and HttpRequest.getFollowRedirects() evaluates to true

Returns:
the redirection URL if the HttpRequest has been redirected (and configured to follow redirects) otherwise returns null

getStatusCode

int getStatusCode()
Returns the integer HTTP response status code.

Returns:
the status code.

getStatusMessage

String getStatusMessage()
Returns the HTTP response status message

Returns:
the status message

getCharset

String getCharset()
The character set from the Content-Type header, or if explicitly provided in the HTTP request, the result of HttpRequest.getCharsetName().

Returns:
the character set to use for reading the response body.

getContentType

String getContentType()
Returns the value of the Content-Type header which indicates the format of the content sent in response to the HTTP request.

Returns:
the content type.

getUrl

URL getUrl()
The URL object used to produce this HttpResponse

Returns:
the URL which originated the response.

getHeaders

Map<String,String> getHeaders()
Returns the headers and their corresponding values in this HTTP response. If multiple values are associated with the same header, they will be be separated by comma. Use getMultiHeaders() to obtain the multiple values in a list.

Returns:
a map of headers and their values.

getMultiHeaders

Map<String,List<String>> getMultiHeaders()
Returns the headers and their corresponding values in this HTTP response. Multiple values can be associated with the same header, use getHeaders() to obtain them as a comma separated sequence

Returns:
a map of headers and their values.

getCookies

Map<String,String> getCookies()
Returns a map with the cookie collection listed in the Set-Cookie header of this response message.

Returns:
the cookies of this HTTP response

close

void close()
Closes any resources associated with reading the request response content.

Specified by:
close in interface Closeable

getContentReader

Reader getContentReader()
Returns a Reader instance to be used to read the content of the response body of this HTTP response.

Returns:
a Reader for the response body.

getContent

String getContent()
Returns a String with the content of the response body of this HTTP response.

Returns:
the response body as a String

readContent

void readContent(HttpResponseReader responseReader)
Reads this HTTP response using a custom class (i.e. a HttpResponseReader). The response body InputStream is available for reading the response body of this message. Useful to process binary content.

Parameters:
responseReader - the custom response reader to process this HttpResponse object.

getRetriesPerformed

int getRetriesPerformed()
Returns the number of retries performed by the UrlReaderProvider until a response was obtained. This number should never be greater than the number of configured retries defined by UrlReaderProvider.getRetries()

Returns:
the number of retries performed to obtain this response object.

getContentLength

long getContentLength()
Returns the length of the content in the body of this HTTP response, as specified in the {code Content-Length} header. If unknown, returns -1.

Returns:
length of the content in the body of this HTTP response. If unknown, returns -1.


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.