T - the type of the implementation classpublic abstract static class H.Request<T extends H.Request> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected InputStream |
inputStream |
protected Reader |
reader |
| Constructor and Description |
|---|
Request() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Class<T> |
_impl()
Returns the class of the implementation.
|
protected abstract void |
_initCookieMap() |
protected abstract String |
_ip()
Returns remote ip address
|
protected void |
_setCookie(String name,
H.Cookie cookie) |
H.Format |
accept()
Return the request
accept |
T |
accept(H.Format fmt)
Set
accept to the request |
T |
accept(H.MediaType mediaType) |
String |
characterEncoding()
Returns encoding of the request
|
long |
contentLength()
Returns the content length of the request
|
H.Format |
contentType()
Return content type of the request
|
<CONTEXT> CONTEXT |
context()
Get the context object from the request instance
|
T |
context(Object context)
Attach a context object to the request instance
|
abstract String |
contextPath()
Returns the context path of the request.
|
H.Cookie |
cookie(String name)
Returns cookie by it's name
|
List<H.Cookie> |
cookies()
Returns all cookies of the request in Iterable
|
protected abstract InputStream |
createInputStream() |
static <T extends H.Request> |
current()
Return a request instance of the current execution context,
For example from a
ThreadLocal |
static <T extends H.Request> |
current(T request)
Set a request instance into the current execution context,
for example into a
ThreadLocal |
String |
domain()
Returns the domain of the request
|
String |
etag() |
boolean |
etagMatches(String etag) |
String |
fullPath()
Returns the full URI path.
|
String |
fullUrl()
Returns the full URL including scheme, domain, port and
full request path plus query string
|
abstract String |
header(String name)
Returns the header content by name.
|
abstract Iterable<String> |
headers(String name)
Returns all header content by name.
|
InputStream |
inputStream()
Returns body of the request as binary data using
InputStream |
String |
ip() |
boolean |
isAjax()
Check if the request is an ajax call
|
boolean |
isModified(String etag,
long since)
Check if the requested resource is modified with etag and
last timestamp (usually the timestamp of a static file e.g.)
|
Locale |
locale()
Returns locale of the request
|
org.osgl.util.C.List<Locale> |
locales()
Returns all locales of the request
|
protected T |
me() |
abstract H.Method |
method()
Returns the HTTP method of the request
|
abstract T |
method(H.Method method)
Set the Http method on this request.
|
abstract Iterable<String> |
paramNames()
Return all parameter names
|
abstract String |
paramVal(String name)
Return a request parameter value by name.
|
abstract String[] |
paramVals(String name)
Returns all values associated with the name specified in the
http request.
|
String |
password()
the Http Basic password
|
abstract String |
path()
Returns the path of the request.
|
int |
port()
Returns the port
|
abstract String |
query()
Returns query string or an empty String if the request
doesn't contains a query string
|
Reader |
reader()
Returns body of the request as binary data using
Reader |
boolean |
readerCreated() |
String |
referer()
This method is an alias of
referer which follows the
HTTP misspelling header name `referer` |
String |
referrer()
Return the "referer(sic)" header value
|
String |
scheme()
Returns the scheme of the request, specifically one of the
"http" and "https"
|
abstract boolean |
secure()
Check if the request was made on a secure channel
|
String |
url()
Alias of
fullPath() |
String |
user()
The Http Basic user
|
org.osgl.web.util.UserAgent |
userAgent() |
String |
userAgentStr() |
protected volatile InputStream inputStream
protected volatile Reader reader
protected abstract Class<T> _impl()
public T context(Object context)
context - the context objectpublic <CONTEXT> CONTEXT context()
CONTEXT - the generic type of the context objectpublic abstract H.Method method()
public abstract T method(H.Method method)
method - the method to setpublic abstract String header(String name)
null is returned
Note header name is case insensitive
name - the name of the headerpublic abstract Iterable<String> headers(String name)
Iterable of String. If there
is no header has the name specified, then an empty iterable
is returned.
Note header name is case insensitive
name - the name of the headerpublic T accept(H.Format fmt)
accept to the requestfmt - the format to be setpublic T accept(H.MediaType mediaType)
public String referrer()
public String referer()
referer which follows the
HTTP misspelling header name `referer`public String etag()
public boolean etagMatches(String etag)
public boolean isAjax()
true if it is an ajax callpublic abstract String path()
HttpServletRequest.getServletPath()
and HttpServletRequest.getPathInfo()
The path starts with "/" but not end with "/"
public abstract String contextPath()
public String fullPath()
contextPath() and path()
The full path starts with "/"public String url()
fullPath()public String fullUrl()
public abstract String query()
public abstract boolean secure()
true if this is a secure requestpublic String scheme()
public String domain()
public int port()
protected abstract String _ip()
public String ip()
public String userAgentStr()
public org.osgl.web.util.UserAgent userAgent()
protected abstract void _initCookieMap()
public H.Cookie cookie(String name)
name - the cookie namenull if not foundpublic List<H.Cookie> cookies()
public boolean isModified(String etag, long since)
etag - the etag to compare with "If_None_Match"
header in browsersince - the last timestamp to compare with
"If_Modified_Since" header in browsertrue if the resource has changed
or false otherwisepublic H.Format contentType()
public String characterEncoding()
public Locale locale()
public org.osgl.util.C.List<Locale> locales()
public long contentLength()
public boolean readerCreated()
protected abstract InputStream createInputStream()
public InputStream inputStream() throws IllegalStateException
InputStreamIllegalStateException - if reader() has already
been called on this request instancepublic Reader reader() throws IllegalStateException
ReaderIllegalStateException - if inputStream() has already
been called on this request instancepublic abstract String paramVal(String name)
null is returned. If
there are multiple values associated with the name, then the
first one is returnedname - the parameter namenull if not foundpublic abstract String[] paramVals(String name)
new String[0] shall be returnedname - the parameter namepublic abstract Iterable<String> paramNames()
Iterable of parameter namespublic String user()
public String password()
protected final T me()
public static <T extends H.Request> T current()
ThreadLocalT - the requestion typepublic static <T extends H.Request> void current(T request)
ThreadLocalT - the response typerequest - the request to be set to current execution contextCopyright © 2017. All Rights Reserved.