Class Request

java.lang.Object
com.renomad.minum.web.Request
All Implemented Interfaces:
IRequest

public final class Request extends Object implements IRequest
  • Constructor Details

    • Request

      public Request(Headers headers, RequestLine requestLine, String remoteRequester, ISocketWrapper socketWrapper, IBodyProcessor bodyProcessor)
      Constructor for a HTTP request
      Parameters:
      remoteRequester - This is the remote address making the request
  • Method Details

    • getHeaders

      public Headers getHeaders()
      Description copied from interface: IRequest
      Get a Headers object, which contains all the headers in the request
      Specified by:
      getHeaders in interface IRequest
    • getRequestLine

      public RequestLine getRequestLine()
      Description copied from interface: IRequest
      Obtain information about the first line. An example of a RequestLine is:
      GET /foo?bar=baz HTTP/1.1

      This is where you look for anything in the request line, like paths or query strings.

      Specified by:
      getRequestLine in interface IRequest
    • getBody

      public Body getBody()
      Description copied from interface: IRequest
      This getter will process the body data fully on the first call, and cache that data for subsequent calls.
      If there is a need to deal with very large data, such as large images or videos, consider using IRequest.getSocketWrapper() instead, which will allow fine-grained control over pulling the bytes off the socket.
      For instance, if expecting a video (a large file), it may be prudent to store the data into a file while it downloads, so that the server does not need to hold the entire file in memory.

      Further explanation:

      The body contains the data beyond the initial status line and headers. For example, you will find HTML, images, and other bulk data stored in the body. If you are expecting data sent in a POST, it is usually found in the body.

      By calling this method, the entire body contents will be read. In the case of ordinary-sized data, this is not a problem. But, for the sake of explanation, if the data were a gigabyte in size, then your server would need to set aside that much in memory for it.

      It is therefore a security concern, and the defaults of the Minum system are set to prevent security failures. It is recommended that the developer handle such large data by another means, such as by using the aforementioned IRequest.getSocketWrapper(). By default, the system will not read the body if the content-length is greater than the size specified by MAX_READ_SIZE_BYTES, described in the Constants class and in the "minum.config" file.

      Specified by:
      getBody in interface IRequest
    • getRemoteRequester

      public String getRemoteRequester()
      Description copied from interface: IRequest
      Gets a string of the ip address of the client sending this request. For example, "123.123.123.123"
      Specified by:
      getRemoteRequester in interface IRequest
    • getSocketWrapper

      public ISocketWrapper getSocketWrapper()
      Description copied from interface: IRequest
      This getter is expected to be used for situations required finer-grained control over the socket, such as when dealing with streaming input like a game or chat, or receiving a very large file like a video. This will enable the user to read and send on the socket - powerful, but requires care.


      Note: This is an unusual method.

      It is an error to call this in addition to IRequest.getBody(). Use one or the other. Mostly, expect to use getBody unless you really know what you are doing, such as streaming situations or custom body protocols.

      Specified by:
      getSocketWrapper in interface IRequest
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUrlEncodedIterable

      public Iterable<UrlEncodedKeyValue> getUrlEncodedIterable()
      Description copied from interface: IRequest
      This method provides an Iterable for getting the key-value pairs of a URL-encoded body in an HTTP request. This method is intended to be used for situations where the developer requires greater control, for example, if allowing large uploads such as videos.
      If this extra level of control is not needed, the developer would benefit more from using the IRequest.getBody() method, which is far more convenient.
      Specified by:
      getUrlEncodedIterable in interface IRequest
    • getMultipartIterable

      public Iterable<StreamingMultipartPartition> getMultipartIterable()
      Description copied from interface: IRequest
      This method provides an Iterable for getting the partitions of a multipart-form formatted body in an HTTP request. This method is intended to be used for situations where the developer requires greater control, for example, if allowing large uploads such as videos.
      If this extra level of control is not needed, the developer would benefit more from using the IRequest.getBody() method, which is far more convenient.
      Specified by:
      getMultipartIterable in interface IRequest