Package org.simpleframework.http.message
Class ConsumerFactory
- java.lang.Object
-
- org.simpleframework.http.message.ConsumerFactory
-
- Direct Known Subclasses:
PartFactory
class ConsumerFactory extends java.lang.Object
TheConsumerFactory
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.
-
-
Constructor Summary
Constructors Constructor Description ConsumerFactory(Allocator allocator, Segment segment)
Constructor for theConsumerFactory
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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
getContentLength()
This is a convenience method that can be used to determine the length of the message body.BodyConsumer
getInstance()
This method is used to create a body consumer to read the body from the pipeline.BodyConsumer
getInstance(long length)
This method is used to create a body consumer to read the body from the pipeline.protected boolean
isChunked(Segment segment)
This is used to extract information from the HTTP header that can be used to determine the type of the body.protected boolean
isFixed(Segment segment)
This is used to extract information from the HTTP header that can be used to determine the type of the body.protected boolean
isUpload(Segment segment)
This is used to extract information from the HTTP header that can be used to determine the type of the body.
-
-
-
Constructor Detail
-
ConsumerFactory
public ConsumerFactory(Allocator allocator, Segment segment)
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 Detail
-
getInstance
public BodyConsumer 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
public BodyConsumer getInstance(long length)
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
protected 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. 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
protected boolean isUpload(Segment segment)
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
protected boolean isChunked(Segment segment)
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
protected boolean isFixed(Segment segment)
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
-
-