Package de.galan.commons.net.flux
Class Response
java.lang.Object
de.galan.commons.net.flux.Response
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
MockCommonHttpClient.MockResponse
Represents the reponse to a http service.
-
Constructor Summary
ConstructorsConstructorDescriptionResponse(HttpURLConnection connection, InputStream dataStream, int statusCode, String contentEncoding, String contentType, Map<String, String> headerFields) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getHeaderField(String name) intbyte[]Converts the inputstream to a string in UTF-8.Converts the inputstream to a string in UTF-8.getStreamAsString(String encoding) Converts the inputstream to a string with the given encoding.getStreamAsString(Charset charset) Converts the inputstream to a string with the given encoding.booleanReturns true if the http status code is between 400 and 499booleanisFailed()Returns true if the http status code is not between 200 and 299booleanReturns true if the http status code is not between 100 and 199booleanReturns true if the http status code is between 300 and 399booleanReturns true if the http status code is between 500 and 599booleanReturns true if the http status code is between 200 and 299voidstoreStream(File file) voidstoreStream(File file, boolean gunzip)
-
Constructor Details
-
Response
public Response(HttpURLConnection connection, InputStream dataStream, int statusCode, String contentEncoding, String contentType, Map<String, String> headerFields)
-
-
Method Details
-
getStream
-
getStreamAsBytearray
Converts the inputstream to a string in UTF-8. Subsequent the inputstream will be empty/closed.- Throws:
IOException
-
getStreamAsString
Converts the inputstream to a string in UTF-8. Subsequent the inputstream will be empty/closed.- Throws:
IOException
-
getStreamAsString
Converts the inputstream to a string with the given encoding. Subsequent the inputstream will be empty/closed.- Throws:
IOException
-
getStreamAsString
Converts the inputstream to a string with the given encoding. Subsequent the inputstream will be empty/closed.- Throws:
IOException
-
storeStream
- Throws:
FileNotFoundExceptionIOException
-
storeStream
- Throws:
FileNotFoundExceptionIOException
-
getStatusCode
public int getStatusCode() -
getContentEncoding
-
getContentType
-
isFailed
public boolean isFailed()Returns true if the http status code is not between 200 and 299 -
isInformational
public boolean isInformational()Returns true if the http status code is not between 100 and 199 -
isSucceded
public boolean isSucceded()Returns true if the http status code is between 200 and 299 -
isRedirection
public boolean isRedirection()Returns true if the http status code is between 300 and 399 -
isClientError
public boolean isClientError()Returns true if the http status code is between 400 and 499 -
isServerError
public boolean isServerError()Returns true if the http status code is between 500 and 599 -
getHeaderField
-
getHeaderFields
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-