Package org.simpleframework.http.message
Class ConsumerFactory
java.lang.Object
org.simpleframework.http.message.ConsumerFactory
- Direct Known Subclasses:
PartFactory
The
ConsumerFactory
object is used to create a factory
for creating consumers. This allows the request to determine the
type of content sent and allows consumption of the request body in
a the manner specified by the HTTP header. This will allow multipart
and chunked content to be consumed from the pipeline.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConsumerFactory
(Allocator allocator, Segment segment) Constructor for theConsumerFactory
object. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
getBoundary
(Segment header) This is used to extract information from the HTTP header that can be used to determine the type of the body.protected long
This is a convenience method that can be used to determine the length of the message body.This method is used to create a body consumer to read the body from the pipeline.getInstance
(long length) This method is used to create a body consumer to read the body from the pipeline.protected boolean
This is used to extract information from the HTTP header that can be used to determine the type of the body.protected boolean
This is used to extract information from the HTTP header that can be used to determine the type of the body.protected boolean
This is used to extract information from the HTTP header that can be used to determine the type of the body.
-
Field Details
-
allocator
This is used to allocate the memory associated with the body. -
segment
This is the header associated with the request body consumed.
-
-
Constructor Details
-
ConsumerFactory
Constructor for theConsumerFactory
object. This will create a factory that makes use of the HTTP header in order to determine the type of the body that is to be consumed.- Parameters:
allocator
- this is the allocator used to allocate memorysegment
- this is the HTTP header used to determine type
-
-
Method Details
-
getInstance
This method is used to create a body consumer to read the body from the pipeline. This will examine the HTTP header associated with the body to determine how to consume the data. This will provide an empty consumer if no specific delimiter was provided.- Returns:
- this returns the consumer used to consume the body
-
getInstance
This method is used to create a body consumer to read the body from the pipeline. This will examine the HTTP header associated with the body to determine how to consume the data. This will provide an empty consumer if no specific delimiter was provided.- Parameters:
length
- this is the length of the body to be consumed- Returns:
- this returns the consumer used to consume the body
-
getBoundary
This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.- Parameters:
header
- this is the header associated with the body- Returns:
- the boundary for a multipart upload body
-
isUpload
This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.- Parameters:
segment
- this is the header associated with the body- Returns:
- true if the content type is that of a multipart body
-
isChunked
This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.- Parameters:
segment
- this is the header associated with the body- Returns:
- true if the body is to be consumed as a chunked body
-
isFixed
This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.- Parameters:
segment
- this is the header associated with the body- Returns:
- true if there was a content length in the header
-
getContentLength
protected long getContentLength()This is a convenience method that can be used to determine the length of the message body. This will determine if there is aContent-Length
header, if it does then the length can be determined, if not then this returns -1.- Returns:
- the content length, or -1 if it cannot be determined
-