public interface MuRequest
Modifier and Type | Method and Description |
---|---|
Optional<String> |
cookie(String name)
Gets the value of the client-sent cookie with the given name
|
Set<Cookie> |
cookies()
Gets all the client-sent cookies
|
String |
formValue(String name)
Gets the form value with the given name, or empty string if there is no form value with that name.
|
List<String> |
formValues(String name)
Gets the form values with the given name, or empty list if there is no form value with that name.
|
Headers |
headers() |
Optional<InputStream> |
inputStream()
The input stream of the request, if there was a request body.
|
Method |
method() |
String |
parameter(String name)
Gets the querystring value with the given name, or empty string if there is no parameter with that name.
|
List<String> |
parameters(String name)
Gets all the querystring parameters with the given name, or an empty list if none are found.
|
String |
readBodyAsString()
Returns the request body as a string.
|
URI |
serverURI()
The URI of the request for this server.
|
URI |
uri()
The URI of the request at the origin.
|
Method method()
URI uri()
If behind a reverse proxy, this URI should be the URI that the client saw when making the request.
URI serverURI()
If behind a reverse proxy, this will be different from uri()
as it is the actual server URI rather
than what the client sees.
Headers headers()
Optional<InputStream> inputStream()
Note: this can only be read once and cannot be used with readBodyAsString()
, formValue(String)
or formValues(String)
.
Optional.empty()
if there is no request body; otherwise the input stream of the request body.String readBodyAsString() throws IOException
This is a blocking call which waits until the whole request is available. If you need the raw bytes, or to stream
the request body, then use the inputStream()
instead.
The content type of the request body is assumed to be UTF-8.
Note: this can only be read once and cannot be used with inputStream()
()}, formValue(String)
or formValues(String)
.
IOException
- if there is an exception during reading the request, e.g. if the HTTP connection is stopped during a requestString parameter(String name)
If there are multiple parameters with the same name, the first one is returned.
name
- The querystring parameter name to getList<String> parameters(String name)
name
- The querystring parameter name to getString formValue(String name) throws IOException
If there are multiple form elements with the same name, the first one is returned.
Note: this cannot be called after a call to inputStream()
or readBodyAsString()
name
- The name of the form element to getIOException
- Thrown when there is an error while reading the form, e.g. if a user closes their
browser before the form is fully read into memory.List<String> formValues(String name) throws IOException
Note: this cannot be called after a call to inputStream()
or readBodyAsString()
name
- The name of the form element to getIOException
- Thrown when there is an error while reading the form, e.g. if a user closes their
browser before the form is fully read into memory.Optional<String> cookie(String name)
name
- The name of the cookieOptional.empty()
if there is no cookie with that name.Copyright © 2017–2018. All rights reserved.