Class PartHeaderConsumer

  • All Implemented Interfaces:
    ByteConsumer, Segment

    class PartHeaderConsumer
    extends SegmentConsumer
    The PartHeaderConsumer object is used to consume the header for a multipart message. This performs a parse of the HTTP headers within the message up to the terminal carriage return and line feed token. Once this had been read the contents of the header are appended to a buffer so they can be read later.
    • Field Detail

      • allocator

        private Allocator allocator
        This is used to allocate the internal buffer for the header.
      • buffer

        private Buffer buffer
        This is the internal buffer used to store the header.
    • Constructor Detail

      • PartHeaderConsumer

        public PartHeaderConsumer​(Allocator allocator)
        Constructor for the PartHeaderConsumer object. An allocator is required so that the header consumer can create a buffer to store the contents of the consumed message.
        Parameters:
        allocator - this is the allocator used to create a buffer
    • Method Detail

      • process

        protected void process()
                        throws java.io.IOException
        This is used to process the header consumer once all of the headers have been read. This will simply parse all of the headers and append the consumed bytes to the internal buffer. Appending the bytes ensures that the whole upload can be put back together as a single byte stream if required.
        Overrides:
        process in class SegmentConsumer
        Throws:
        java.io.IOException
      • append

        private void append()
                     throws java.io.IOException
        This is used to allocate the internal buffer and append the consumed bytes to the buffer. Once the header is added to the internal buffer this is finished and the next part of the upload can be consumed.
        Throws:
        java.io.IOException