public interface IBodyProcessor
An interface for the
BodyProcessor
implementation.
Solely created to provide better testing access-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Just providing a sane upper limit, with a little extra for safety factor.static final int
The largest size name we will allow is 50 bytes, that is 50 ascii characters.static final int
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. -
Method Summary
Modifier and TypeMethodDescriptionextractData
(InputStream is, Headers h) read the body if one exists
There are really only two ways to read the body.getMultiPartIterable
(InputStream inputStream, String boundaryValue, int contentLength) Return an iterable for stepping through the multipart partitions.getUrlEncodedDataIterable
(InputStream inputStream, long contentLength) Return an iterable for stepping through the key-value pairs of URL-encoded data.
-
Field Details
-
MAX_SIZE_DATA_RETURNED_IN_EXCEPTION
static final int MAX_SIZE_DATA_RETURNED_IN_EXCEPTIONWhen 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_BYTESThe 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_ENCODEDJust providing a sane upper limit, with a little extra for safety factor.- See Also:
-
-
Method Details
-
extractData
read the body if one exists
There are really only two ways to read the body.- the client tells us how many bytes to read
- 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
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 usingextractData(InputStream, Headers)
, which puts the entire data into memory.- Parameters:
inputStream
- TheInputStream
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
- TheInputStream
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.
-