Package org.eclipse.sw360.http
Interface Response
-
public interface ResponseAn interface describing the response of an HTTP request.
This interface is used by
ResponseProcessorobjects to access the data received from the HTTP server. It provides query methods for the typical information, such as the HTTP status code, the headers, or the response body as a stream.Note that underlying HTTP libraries used to implement this interface typically place some restrictions on the usage of the methods provided here, especially with regards to the response body. So an implementation should expect that the body stream can be consumed only once. On the other hand, it is not necessary to explicitly release any of the resources that might be hold by a response object; this is done by the framework.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStreambodyStream()Returns anInputStreamfor the body of this response; so the data received from the server can be streamed.Stringheader(String name)Returns the value of the header with the given name.Set<String>headerNames()Returns a set with the names of the headers contained in the response.booleanisSuccess()Returns a flag whether the request was successful.intstatusCode()Returns the HTTP status code of this response.
-
-
-
Method Detail
-
statusCode
int statusCode()
Returns the HTTP status code of this response.- Returns:
- the HTTP status code
-
isSuccess
boolean isSuccess()
Returns a flag whether the request was successful. This is a shortcut for testing thestatusCode()against a range of well-known HTTP status codes. For certain use cases with special requirements for the codes returned by the server, it may be necessary to do the check manually.- Returns:
- true if the request has been successful; false otherwise
-
headerNames
Set<String> headerNames()
Returns a set with the names of the headers contained in the response.- Returns:
- a set with the names of the defined headers
-
header
String header(String name)
Returns the value of the header with the given name.- Parameters:
name- the name of the header in question- Returns:
- the value of this header or null if it is not present
-
bodyStream
InputStream bodyStream()
Returns anInputStreamfor the body of this response; so the data received from the server can be streamed. Result is never null; if the request did not yield a response body, an empty stream is returned.- Returns:
- an
InputStreamto access the response body
-
-