public interface HttpMessage
Modifier and Type | Method and Description |
---|---|
Optional<String> |
getCharacterEncoding()
Returns the character encoding specified in the
Content-Type header,
or Optional.empty() if there is no Content-Type header or it does not have the
charset parameter. |
long |
getContentLength()
Returns the numeric value of the
Content-Length header. |
Optional<String> |
getContentType()
Returns the value of the
Content-Type header, if any. |
default Optional<String> |
getFirstHeader(String name)
Convenience method that returns the value of the first header with the given name.
|
Map<String,List<String>> |
getHeaders()
Returns a map describing the headers of this HTTP request, or this part of a multipart
request.
|
InputStream |
getInputStream()
Returns an
InputStream that can be used to read the body of this HTTP request. |
BufferedReader |
getReader()
Returns a
BufferedReader that can be used to read the text body of this HTTP request. |
Optional<String> getContentType()
Content-Type
header, if any.long getContentLength()
Content-Length
header.Optional<String> getCharacterEncoding()
Content-Type
header,
or Optional.empty()
if there is no Content-Type
header or it does not have the
charset
parameter.InputStream getInputStream() throws IOException
InputStream
that can be used to read the body of this HTTP request.
Every call to this method on the same HttpMessage
will return the same object.
This method is typically used to read binary data. If the body is text, the
getReader()
method is more appropriate.IOException
- if a valid InputStream
cannot be returned for some reason.IllegalStateException
- if getReader()
has already been called on this instance.BufferedReader getReader() throws IOException
BufferedReader
that can be used to read the text body of this HTTP request.
Every call to this method on the same HttpMessage
will return the same object.IOException
- if a valid BufferedReader
cannot be returned for some reason.IllegalStateException
- if getInputStream()
has already been called on this
instance.Map<String,List<String>> getHeaders()
Content-Type: text/plain Some-Header: some value Some-Header: another value...then the returned value will map
Content-Type
to a one-element list containing
text/plain
, and Some-Header
to a two-element list containing some value
and another value
.default Optional<String> getFirstHeader(String name)
Content-Type: text/plain Some-Header: some value Some-Header: another value...then
getFirstHeader("Some-Header")
will return Optional.of("some value")
,
and getFirstHeader("Another-Header")
will return Optional.empty()
.Copyright © 2020. All rights reserved.