Interface IBodyProcessor


public interface IBodyProcessor
An interface for the BodyProcessor implementation. Solely created to provide better testing access
  • Field Details

    • MAX_SIZE_DATA_RETURNED_IN_EXCEPTION

      static final int MAX_SIZE_DATA_RETURNED_IN_EXCEPTION
      When parsing fails, we would like to send the raw text back to the user so the development team can determine why parsing went awry. But, when we are sent a huge file, we would rather not include all that data in the logs. So we will cap out at this value.
      See Also:
    • MAX_KEY_SIZE_BYTES

      static final int MAX_KEY_SIZE_BYTES
      The largest size name we will allow is 50 bytes, that is 50 ascii characters. There is no way anyone would benefit from having keys larger than this, unless they are attacking us, or using the system in different ways than its intended design.
      See Also:
    • MAX_BODY_KEYS_URL_ENCODED

      static final int MAX_BODY_KEYS_URL_ENCODED
      Just providing a sane upper limit, with a little extra for safety factor.
      See Also:
  • Method Details

    • extractData

      Body extractData(InputStream is, Headers h)
      read the body if one exists
      There are really only two ways to read the body.
      1. the client tells us how many bytes to read
      2. the client uses "transfer-encoding: chunked"

      Note: we don't read chunked data.

      it is absolutely critical that the client gives us a way to know ahead of time how many bytes to read, so we (the server) can stop reading at precisely the right point. There's simply no other way to reasonably do this.

    • getUrlEncodedDataIterable

      Iterable<UrlEncodedKeyValue> getUrlEncodedDataIterable(InputStream inputStream, long contentLength)
      Return an iterable for stepping through the key-value pairs of URL-encoded data.
      If the incoming Request body is URL-encoded, you may optionally use this method to obtain the data more incrementally than by using extractData(InputStream, Headers), which puts the entire data into memory.
      Parameters:
      inputStream - The InputStream is set at the beginning of the body in the Request. The first read will return the first byte of body data.
      contentLength - The length of data in the body. This is obtained from the content-length header.
    • getMultiPartIterable

      Iterable<StreamingMultipartPartition> getMultiPartIterable(InputStream inputStream, String boundaryValue, int contentLength)
      Return an iterable for stepping through the multipart partitions.
      Parameters:
      inputStream - The InputStream is set at the beginning of the body in the Request. The first read will return the first byte of body data.
      boundaryValue - this is a string value, randomly-generated, from the user agent (i.e. the browser), designating the edge of data partitions. It can be found in the content-type header, if the type is multipart.
      contentLength - The length of data in the body. This is obtained from the content-length header.