Package ortus.boxlang.web.exchange
Interface IBoxHTTPExchange
public interface IBoxHTTPExchange
I represent a web request and response
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResponseCookie
(BoxCookie cookie) Adds the specified cookie to the response.void
addResponseHeader
(String name, String value) Adds a response header with the given name and value.void
Forces any content in the buffer to be written to the client.void
getRequestAttribute
(String name) Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists.Returns a Map containing the attributes available to this request.Returns the name of the authentication scheme used to protect the servlet.Retrieves the body of the request.Returns the name of the character encoding used in the body of this request.long
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.Returns the MIME type of the body of the request, ornull
if the type is not known.Returns the portion of the request URI that indicates the context of the request.getRequestCookie
(String name) Get a request cookie by nameReturns an array containing all of theCookie
objects the client sent with this request.Returns a java.util.Map of the form parameters of this request.getRequestHeader
(String name) Returns the value of the specified request header as aString
.Returns a map of HTTP request headers where the keys are header names and the values are arrays of header values.Returns the Internet Protocol (IP) address representing the interface on which the request was received.Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header.Returns anEnumeration
ofLocale
objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.Returns the fully qualified name of the address returned by getLocalAddr().int
Returns the Internet Protocol (IP) port number representing the interface on which the request was received.Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.Returns any extra path information associated with the URL the client sent when it made this request.Returns any extra path information after the servlet name but before the query string, and translates it to a real path.Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.Returns the query string that is contained in the request URL after the path.Returns the Internet Protocol (IP) of the remote end of the connection on which the request was received.Returns the fully qualified name of the address returned by getRemoteAddr().int
Returns the Internet Protocol (IP) source port the remote end of the connection on which the request was received.Returns the login of the user making this request, if the user has been authenticated, ornull
if the user has not been authenticated.Returns the name of the scheme used to make this request, for example,http
,https
, orftp
.Returns the host name of the server to which the request was sent.int
Returns the port number to which the request was sent.Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.Reconstructs the URL the client used to make the request.Returns a java.util.Map of the URL parameters of this request.Returns ajava.security.Principal
object containing the name of the current authenticated user.getResponseHeader
(String name) Gets the value of the response header with the given name.Gets the values of the response headersint
Gets the current status code of this response.Returns aPrintWriter
object that can send character text to the client.Returns data about multi-part file uploads that were processed in the request.Get the BoxLang context for this requestboolean
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
Returns a boolean indicating if the response has been started.default boolean
REQUEST METHODSvoid
removeRequestAttribute
(String name) Removes an attribute from this request.void
Clears the content of the underlying buffer in the response without clearing headers or status code.void
sendResponseBinary
(byte[] data) Send binary data as response.void
sendResponseFile
(File file) Send a file as response.void
setRequestAttribute
(String name, Object o) Stores an attribute in this request.void
setResponseHeader
(String name, String value) Sets a response header with the given name and value.void
setResponseStatus
(int sc) Sets the status code for this response.void
setResponseStatus
(int sc, String sm) Sets the status code and reason phrase for this response.void
setWebContext
(WebRequestBoxContext context) Set the BoxLang context for this request
-
Method Details
-
forward
-
setWebContext
Set the BoxLang context for this request- Parameters:
context
- The BoxLang context
-
getWebContext
WebRequestBoxContext getWebContext()Get the BoxLang context for this request- Returns:
- The BoxLang context
-
isTextBasedContentType
default boolean isTextBasedContentType()REQUEST METHODS -
getRequestAuthType
String getRequestAuthType()Returns the name of the authentication scheme used to protect the servlet. All servlet containers support basic, form and client certificate authentication, and may additionally support digest authentication. If the servlet is not authenticatednull
is returned. -
getRequestCookies
BoxCookie[] getRequestCookies()Returns an array containing all of theCookie
objects the client sent with this request. This method returnsnull
if no cookies were sent. -
getRequestCookie
Get a request cookie by name- Parameters:
name
- the name of the cookie- Returns:
- the cookie or null if not found
-
getRequestHeaderMap
Returns a map of HTTP request headers where the keys are header names and the values are arrays of header values. -
getRequestHeader
Returns the value of the specified request header as aString
. If the request did not include a header of the specified name, this method returnsnull
. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header. -
getRequestMethod
String getRequestMethod()Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. -
getRequestPathInfo
String getRequestPathInfo()Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character. -
getRequestPathTranslated
String getRequestPathTranslated()Returns any extra path information after the servlet name but before the query string, and translates it to a real path. -
getRequestContextPath
String getRequestContextPath()Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string. -
getRequestQueryString
String getRequestQueryString()Returns the query string that is contained in the request URL after the path. This method returnsnull
if the URL does not have a query string. -
getRequestRemoteUser
String getRequestRemoteUser()Returns the login of the user making this request, if the user has been authenticated, ornull
if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. -
getRequestUserPrincipal
Principal getRequestUserPrincipal()Returns ajava.security.Principal
object containing the name of the current authenticated user. If the user has not been authenticated, the method returnsnull
. -
getRequestURI
String getRequestURI()Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. -
getRequestURL
StringBuffer getRequestURL()Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters. -
getRequestAttribute
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists. -
getRequestAttributeMap
Returns a Map containing the attributes available to this request. -
getRequestCharacterEncoding
String getRequestCharacterEncoding()Returns the name of the character encoding used in the body of this request. This method returnsnull
if no request encoding character encoding has been specified. -
getRequestContentLength
long getRequestContentLength()Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. -
getRequestContentType
String getRequestContentType()Returns the MIME type of the body of the request, ornull
if the type is not known.- Returns:
- a
String
containing the name of the MIME type of the request, or null if the type is not known
-
getRequestFormMap
Returns a java.util.Map of the form parameters of this request. This also processes any multi-part form data since the request body is parsed at this time -
getUploadData
IBoxHTTPExchange.FileUpload[] getUploadData()Returns data about multi-part file uploads that were processed in the request. The order of the file upload objects is the order they were sent in the form. (note when the file component is called with action="upload" and no file name, the first file is processed.) Each FileUpload object contains the temporary file path and the original file name. -
getRequestURLMap
Returns a java.util.Map of the URL parameters of this request. -
getRequestProtocol
String getRequestProtocol()Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. -
getRequestScheme
String getRequestScheme()Returns the name of the scheme used to make this request, for example,http
,https
, orftp
. Different schemes have different rules for constructing URLs, as noted in RFC 1738. -
getRequestServerName
String getRequestServerName()Returns the host name of the server to which the request was sent. It may be derived from a protocol specific mechanism, such as theHost
header, or the HTTP/2 authority, or RFC 7239, otherwise the resolved server name or the server IP address.- Returns:
- a
String
containing the name of the server
-
getRequestServerPort
int getRequestServerPort()Returns the port number to which the request was sent. It may be derived from a protocol specific mechanism, such as theHost
header, or HTTP authority, or RFC 7239, otherwise the server port where the client connection was accepted on. -
getRequestBody
Object getRequestBody()Retrieves the body of the request. Will be a string or a byte array depending on the content type. -
getRequestRemoteAddr
String getRequestRemoteAddr()Returns the Internet Protocol (IP) of the remote end of the connection on which the request was received. By default this is either the address of the client or last proxy that sent the request. In some cases a protocol specific mechanism, such as RFC 7239, may be used to obtain an address different to that of the actual TCP/IP connection. -
getRequestRemoteHost
String getRequestRemoteHost()Returns the fully qualified name of the address returned by getRemoteAddr(). If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the IP address. -
setRequestAttribute
Stores an attribute in this request. Attributes are reset between requests. -
removeRequestAttribute
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled. -
getRequestLocale
Locale getRequestLocale()Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server. -
getRequestLocales
Enumeration<Locale> getRequestLocales()Returns anEnumeration
ofLocale
objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns anEnumeration
containing oneLocale
, the default locale for the server. -
isRequestSecure
boolean isRequestSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. -
getRequestRemotePort
int getRequestRemotePort()Returns the Internet Protocol (IP) source port the remote end of the connection on which the request was received. By default this is either the port of the client or last proxy that sent the request. In some cases, protocol specific mechanisms such as RFC 7239 may be used to obtain a port different to that of the actual TCP/IP connection. -
getRequestLocalName
String getRequestLocalName()Returns the fully qualified name of the address returned by getLocalAddr(). If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the IP address. -
getRequestLocalAddr
String getRequestLocalAddr()Returns the Internet Protocol (IP) address representing the interface on which the request was received. In some cases a protocol specific mechanism, such as RFC 7239, may be used to obtain an address different to that of the actual TCP/IP connection. -
getRequestLocalPort
int getRequestLocalPort()Returns the Internet Protocol (IP) port number representing the interface on which the request was received. In some cases, a protocol specific mechanism such as RFC 7239 may be used to obtain an address different to that of the actual TCP/IP connection. -
isResponseStarted
boolean isResponseStarted()Returns a boolean indicating if the response has been started.- Returns:
- true if the response has been started, false otherwise
-
addResponseCookie
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie. -
setResponseHeader
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. ThecontainsHeader
method can be used to test for the presence of a header before setting its value. -
addResponseHeader
Adds a response header with the given name and value. This method allows response headers to have multiple values. -
setResponseStatus
void setResponseStatus(int sc) Sets the status code for this response. -
setResponseStatus
Sets the status code and reason phrase for this response. -
getResponseStatus
int getResponseStatus()Gets the current status code of this response. -
getResponseHeader
Gets the value of the response header with the given name. -
getResponseHeaderMap
Gets the values of the response headers -
getResponseWriter
PrintWriter getResponseWriter()Returns aPrintWriter
object that can send character text to the client. ThePrintWriter
uses the character encoding returned by getCharacterEncoding. If the response's character encoding has not been specified as described ingetCharacterEncoding
(i.e., the method just returns the default valueISO-8859-1
),getWriter
updates it toISO-8859-1
. -
sendResponseBinary
void sendResponseBinary(byte[] data) Send binary data as response. Rest any other response body content.- Parameters:
data
- the binary data to send
-
sendResponseFile
Send a file as response. Rest any other response body content.- Parameters:
file
- the file to send
-
flushResponseBuffer
void flushResponseBuffer()Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written. -
resetResponseBuffer
void resetResponseBuffer()Clears the content of the underlying buffer in the response without clearing headers or status code. If the response has been committed, this method throws anIllegalStateException
.
-