Class HttpUtils
java.lang.Object
org.eclipse.rdf4j.http.client.spi.HttpUtils
Utility methods for working with
HttpResponse instances.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringtoString(HttpResponse response) Reads the response body into aString, using the charset declared in theContent-Typeheader.static StringtoString(HttpResponse response, Charset defaultCharset) Reads the response body into aString, using the charset declared in theContent-Typeheader.
-
Method Details
-
toString
Reads the response body into aString, using the charset declared in theContent-Typeheader. If nocharsetparameter is present,ISO-8859-1is used as the default, consistent with the HTTP/1.1 specification and the behaviour of Apache HttpClient'sEntityUtils.toString().If the response has no body (e.g. HTTP 204 No Content), an empty string is returned.
- Parameters:
response- the response whose body is to be read; the caller is responsible for closing the response- Returns:
- the response body as a string, or an empty string if there is no body
- Throws:
IOException- if reading the body fails
-
toString
Reads the response body into aString, using the charset declared in theContent-Typeheader. If nocharsetparameter is present,defaultCharsetis used instead.If the response has no body (e.g. HTTP 204 No Content), an empty string is returned.
- Parameters:
response- the response whose body is to be read; the caller is responsible for closing the responsedefaultCharset- the charset to use when none is declared in theContent-Typeheader- Returns:
- the response body as a string, or an empty string if there is no body
- Throws:
IOException- if reading the body fails
-