Package net.jadler
Class Request
- java.lang.Object
-
- net.jadler.Request
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequest.BuilderA builder class forRequestinstances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Request.Builderbuilder()byte[]getBodyAsBytes()InputStreamgetBodyAsStream()Returns the body content as anInputStreaminstance.StringgetBodyAsString()StringgetContentType()CharsetgetEncoding()KeyValuesgetHeaders()StringgetMethod()KeyValuesgetParameters()URIgetURI()StringtoString()
-
-
-
Method Detail
-
builder
public static Request.Builder builder()
- Returns:
- new builder for creating
Requestinstances
-
getMethod
public String getMethod()
- Returns:
- http method
-
getURI
public URI getURI()
- Returns:
- URI of the request. For example http://localhost:8080/test/file?a=4
-
getParameters
public KeyValues getParameters()
- Returns:
- all http parameters (read from both query string and request body) from this request.
Never returns
null
-
getHeaders
public KeyValues getHeaders()
- Returns:
- all http headers from this request. Never returns
null
-
getBodyAsStream
public InputStream getBodyAsStream()
Returns the body content as anInputStreaminstance. This method can be called multiple times always returning valid, readable stream.- Returns:
- request body as an
InputStreaminstance
-
getBodyAsBytes
public byte[] getBodyAsBytes()
- Returns:
- request body as an array of bytes
-
getBodyAsString
public String getBodyAsString()
- Returns:
- request body as a string (if the body is empty, returns an empty string). If no encoding was
set using the
Content-Typeheader ISO-8859-1 will be used (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html).
-
getContentType
public String getContentType()
- Returns:
- value of the
Content-Typeheader.
-
getEncoding
public Charset getEncoding()
- Returns:
- request body encoding set by the
Content-Typeheader ornullif not set
-
-