Interface IBoxHTTPExchange


public interface IBoxHTTPExchange
I represent a web request and response
  • Method Details

    • forward

      void forward(String URI)
    • setWebContext

      void setWebContext(WebRequestBoxContext context)
      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 authenticated null is returned.
    • getRequestCookies

      BoxCookie[] getRequestCookies()
      Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.
    • getRequestCookie

      BoxCookie getRequestCookie(String name)
      Get a request cookie by name
      Parameters:
      name - the name of the cookie
      Returns:
      the cookie or null if not found
    • getRequestHeaderMap

      Map<String,String[]> getRequestHeaderMap()
      Returns a map of HTTP request headers where the keys are header names and the values are arrays of header values.
    • getRequestHeader

      String getRequestHeader(String name)
      Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. 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 returns null 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, or null 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 a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null.
    • 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

      Object getRequestAttribute(String name)
      Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
    • getRequestAttributeMap

      Map<String,Object> 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 returns null 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, or null 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

      Map<String,String[]> 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

      Map<String,String[]> 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, or ftp. 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 the Host 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 the Host 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

      void setRequestAttribute(String name, Object o)
      Stores an attribute in this request. Attributes are reset between requests.
    • removeRequestAttribute

      void removeRequestAttribute(String name)
      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 preferred Locale 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 an Enumeration of Locale 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 an Enumeration containing one Locale, 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

      void addResponseCookie(BoxCookie cookie)
      Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.
    • setResponseHeader

      void setResponseHeader(String name, String value)
      Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.
    • addResponseHeader

      void addResponseHeader(String name, String value)
      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

      void setResponseStatus(int sc, String sm)
      Sets the status code and reason phrase for this response.
    • getResponseStatus

      int getResponseStatus()
      Gets the current status code of this response.
    • getResponseHeader

      String getResponseHeader(String name)
      Gets the value of the response header with the given name.
    • getResponseHeaderMap

      Map<String,String[]> getResponseHeaderMap()
      Gets the values of the response headers
    • getResponseWriter

      PrintWriter getResponseWriter()
      Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding returned by getCharacterEncoding. If the response's character encoding has not been specified as described in getCharacterEncoding (i.e., the method just returns the default value ISO-8859-1), getWriter updates it to ISO-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

      void sendResponseFile(File file)
      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 an IllegalStateException.