http/request
Documentation
- source: http/request.ts
Overview
Classes
Request
isValid()
Determines whether the current thread is handling a valid HTTP request.
tsstatic isValid(): boolean;Returns
- Type:
boolean- Description: `true` if called in a valid HTTP request context, otherwise `false`.
getMethod()
Returns the HTTP method (GET, POST, PUT, DELETE, etc.).
tsstatic getMethod(): string;Returns
- Type:
string- Description:
getRemoteUser()
Returns the authenticated remote user name if available.
tsstatic getRemoteUser(): string;Returns
- Type:
string- Description:
getPathInfo()
Returns the portion of the request path following the servlet path.
tsstatic getPathInfo(): string;Returns
- Type:
string- Description:
getPathTranslated()
Returns the translated file system path for the request.
tsstatic getPathTranslated(): string;Returns
- Type:
string- Description:
getHeader()
Returns the value of a specific HTTP header.
tsstatic getHeader(name: string): string;
Parameter Type Description namestringHeader name to retrieve. Returns
- Type:
string- Description: The header value or `undefined` if not found.
isUserInRole()
Checks whether the remote user has the given role.
tsstatic isUserInRole(role: string): boolean;
Parameter Type Description rolestringThe role name to check. Returns
- Type:
boolean- Description:
getAttribute()
Returns a request attribute value previously associated with the request.
tsstatic getAttribute(name: string): string;
Parameter Type Description namestringThe attribute name. Returns
- Type:
string- Description: A string value or `undefined`.
getAuthType()
Returns the authentication type if known (BASIC, CLIENT_CERT, etc.).
tsstatic getAuthType(): string;Returns
- Type:
string- Description:
getCookies()
Returns all cookies sent with the request.
tsstatic getCookies(): void;Returns
- Type:
void- Description: An array of Cookie objects.
getAttributeNames()
Returns all available request attribute names.
tsstatic getAttributeNames(): void;Returns
- Type:
void- Description:
getCharacterEncoding()
Returns the character encoding used in the request body.
tsstatic getCharacterEncoding(): string;Returns
- Type:
string- Description:
getContentLength()
Returns the size of the request body in bytes, if known.
tsstatic getContentLength(): number;Returns
- Type:
number- Description:
getHeaders()
Returns all values of a specific header.
tsstatic getHeaders(name: string): void;
Parameter Type Description namestringHeader name to retrieve. Returns
- Type:
void- Description:
getContentType()
Returns the MIME content type of the request body.
tsstatic getContentType(): string;Returns
- Type:
string- Description:
getBytes()
Returns the raw request body as a byte array.
tsstatic getBytes(): void;Returns
- Type:
void- Description:
getText()
Returns the request body as text. This is computed once and cached.
tsstatic getText(): string;Returns
- Type:
string- Description:
json()
Returns the request body parsed as JSON if valid.
tsstatic json(): void;Returns
- Type:
void- Description: A JSON object or `undefined` if parsing fails.
getJSON()
Same as json(); explicit form.
tsstatic getJSON(): void;Returns
- Type:
void- Description:
getParameter()
Returns a request parameter value.
tsstatic getParameter(name: string): string;
Parameter Type Description namestringReturns
- Type:
string- Description:
getParameters()
Returns a map of request parameters to arrays of values.
tsstatic getParameters(): void;Returns
- Type:
void- Description:
getResourcePath()
Returns the allocated request resource path.
tsstatic getResourcePath(): string;Returns
- Type:
string- Description:
getHeaderNames()
Returns all header names.
tsstatic getHeaderNames(): void;Returns
- Type:
void- Description:
getParameterNames()
Returns all parameter names.
tsstatic getParameterNames(): void;Returns
- Type:
void- Description:
getParameterValues()
Returns all values for a given parameter name.
tsstatic getParameterValues(name: string): void;
Parameter Type Description namestringReturns
- Type:
void- Description:
getProtocol()
Returns the HTTP protocol version.
tsstatic getProtocol(): string;Returns
- Type:
string- Description:
getScheme()
Returns the transport scheme (e.g., http, https).
tsstatic getScheme(): string;Returns
- Type:
string- Description:
getContextPath()
Returns the context path of the request.
tsstatic getContextPath(): string;Returns
- Type:
string- Description:
getServerName()
Returns the server host name.
tsstatic getServerName(): string;Returns
- Type:
string- Description:
getServerPort()
Returns the server port number.
tsstatic getServerPort(): number;Returns
- Type:
number- Description:
getQueryString()
Returns the full raw query string.
tsstatic getQueryString(): string;Returns
- Type:
string- Description:
getQueryParametersMap()
Parses the query string and returns a map of parameter keys to values. If the same key appears multiple times, values are collected into arrays.
tsstatic getQueryParametersMap(): void;Returns
- Type:
void- Description:
getRemoteAddress()
Returns the remote client IP address.
tsstatic getRemoteAddress(): string;Returns
- Type:
string- Description:
getRemoteHost()
Returns the remote client host name.
tsstatic getRemoteHost(): string;Returns
- Type:
string- Description:
setAttribute()
Assigns a new attribute to the request.
tsstatic setAttribute(name: string, value: string): void;
Parameter Type Description namestringvaluestringReturns
- Type:
void- Description:
removeAttribute()
Removes an attribute from the request.
tsstatic removeAttribute(name: string): void;
Parameter Type Description namestringReturns
- Type:
void- Description:
getLocale()
Returns the client locale preferences.
tsstatic getLocale(): any;Returns
- Type:
any- Description:
getRequestURI()
Returns the full request URI.
tsstatic getRequestURI(): string;Returns
- Type:
string- Description:
isSecure()
Returns `true` if the request was made over HTTPS.
tsstatic isSecure(): boolean;Returns
- Type:
boolean- Description:
getRequestURL()
Returns the full request URL including protocol and host.
tsstatic getRequestURL(): string;Returns
- Type:
string- Description:
getServicePath()
Returns the internal service path for routing.
tsstatic getServicePath(): string;Returns
- Type:
string- Description:
getRemotePort()
Returns the remote client port number.
tsstatic getRemotePort(): number;Returns
- Type:
number- Description:
getLocalName()
Returns the local network host name.
tsstatic getLocalName(): string;Returns
- Type:
string- Description:
getLocalAddress()
Returns the local IP address.
tsstatic getLocalAddress(): string;Returns
- Type:
string- Description:
getLocalPort()
Returns the server local port number handling the request.
tsstatic getLocalPort(): number;Returns
- Type:
number- Description:
getInputStream()
Returns the request body as a binary input stream.
Useful for processing binary uploads.
tsstatic getInputStream(): InputStream;Returns
- Type:
InputStream- Description:
