public class Request extends Object
Class encapsulating HTTP request data
| Constructor and Description |
|---|
Request(com.sun.net.httpserver.HttpExchange exchange,
Express express) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMiddlewareContent(Filter middleware,
Object middlewareData)
Add a the content from a middleware
|
InetAddress |
getAddress()
Returns the InetAddress from the client.
|
Express |
getApp() |
List<Authorization> |
getAuthorization() |
InputStream |
getBody() |
long |
getContentLength()
Returns the to long parsed content-length.
|
String |
getContentType() |
String |
getContext()
Returns the corresponding context.
|
Cookie |
getCookie(String name)
Get a request cookie by name.
|
HashMap<String,Cookie> |
getCookies()
Return all cookies from this request.
|
String |
getFormQuery(String name)
Returns a query from a form which uses the 'application/x-www-form-urlencoded' request header.
|
HashMap<String,String> |
getFormQuerys()
Returns all query's from an x-www-form-urlencoded body.
|
List<String> |
getHeader(String header)
Returns an header value.
|
String |
getHost() |
String |
getIp()
Returns the IP-Address from the client.
|
String |
getMethod() |
Object |
getMiddlewareContent(String name)
Get the data from a specific middleware by name (Also the reason
why the interface ExpressFilter implements a getName())
|
String |
getParam(String param)
Returns an param from a dynamic url.
|
HashMap<String,String> |
getParams()
Returns all params from the url.
|
String |
getPath() |
String |
getProtocol()
The connection protocol HTTP/1.0, HTTP/1.1 etc.
|
String |
getQuery(String name)
Returns the value from the url-query.
|
HashMap<String,String> |
getQuerys()
Return all url-query's.
|
URI |
getURI() |
String |
getUserAgent() |
boolean |
hasAuthorization() |
boolean |
isFresh()
Checks if the connection is 'fresh'
It is true if the cache-control request header doesn't have a no-cache directive, the if-modified-since request header is specified
and last-modified request header is equal to or earlier than the modified response header or if-none-match request header is *.
|
boolean |
isSecure()
Returns whenever the connection is over HTTPS.
|
boolean |
isStale()
Indicates whether the request is "stale" and is the opposite of req.fresh
|
boolean |
isXHR()
Returns true if the 'X-Requested-With' header field is 'XMLHttpRequest'.
|
void |
pipe(OutputStream os,
int bufferSize)
Pipe the body from this request to an OutputStream.
|
void |
pipe(Path f,
int bufferSize)
Pipe the body from this request to an file.
|
void |
setContext(String context)
Set the corresponding context.
|
void |
setParams(HashMap<String,String> params)
Set the params.
|
public Request(com.sun.net.httpserver.HttpExchange exchange,
Express express)
public InputStream getBody()
public void pipe(OutputStream os, int bufferSize) throws IOException
os - The OutputStream.bufferSize - Buffer-size, eg. 4096.IOException - If an IO-Error occurs.public void pipe(Path f, int bufferSize) throws IOException
f - The target filebufferSize - Buffer-size, eg. 4096.IOException - If an IO-Error occurs.public Cookie getCookie(String name)
name - The cookie name.public HashMap<String,Cookie> getCookies()
public void addMiddlewareContent(Filter middleware, Object middlewareData)
middleware - The middlewaremiddlewareData - The data from the middlewarepublic Object getMiddlewareContent(String name)
name - The middleware namepublic String getUserAgent()
public String getHost()
public InetAddress getAddress()
public String getIp()
public String getContentType()
public long getContentLength()
public String getPath()
public URI getURI()
public String getMethod()
public boolean isFresh()
public boolean isStale()
public boolean isSecure()
public boolean isXHR()
public String getProtocol()
public List<Authorization> getAuthorization()
public boolean hasAuthorization()
public String getFormQuery(String name)
name - The name.public String getParam(String param)
param - The param.public String getQuery(String name)
name - The name.public HashMap<String,String> getFormQuerys()
public HashMap<String,String> getParams()
public void setParams(HashMap<String,String> params)
params - Request parameterpublic String getContext()
public void setContext(String context)
context - The corresponding context.public HashMap<String,String> getQuerys()
public List<String> getHeader(String header)
header - The header namepublic Express getApp()
Copyright © 2019. All rights reserved.