Class PausableHttpPostRequestEncoder

  • All Implemented Interfaces:
    io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>

    public class PausableHttpPostRequestEncoder
    extends Object
    implements io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
    A copy of HttpPostRequestEncoder that supports pause/resume This encoder will help to encode Request for a FORM as POST.

    According to RFC 7231, POST, PUT and OPTIONS allow to have a body. This encoder will support widely all methods except TRACE since the RFC notes for GET, DELETE, HEAD and CONNECT: (replaces XXX by one of these methods)

    "A payload within a XXX request message has no defined semantics; sending a payload body on a XXX request might cause some existing implementations to reject the request."

    On the contrary, for TRACE method, RFC says:

    "A client MUST NOT send a message body in a TRACE request."

    • Field Detail

      • WAIT_MARKER

        public static final io.netty.handler.codec.http.HttpContent WAIT_MARKER
    • Method Detail

      • cleanFiles

        public void cleanFiles()
        Clean all HttpDatas (on Disk) for the current request.
      • isMultipart

        public boolean isMultipart()
        True if this request is a Multipart request
        Returns:
        True if this request is a Multipart request
      • getBodyListAttributes

        public List<io.netty.handler.codec.http.multipart.InterfaceHttpData> getBodyListAttributes()
        This getMethod returns a List of all InterfaceHttpData from body part.
        Returns:
        the list of InterfaceHttpData from Body part
      • finalizeRequest

        public io.netty.handler.codec.http.HttpRequest finalizeRequest()
                                                                throws PausableHttpPostRequestEncoder.ErrorDataEncoderException
        Finalize the request by preparing the Header in the request and returns the request ready to be sent.
        Once finalized, no data must be added.
        If the request does not need chunk (isChunked() == false), this request is the only object to send to the remote server.
        Returns:
        the request object (chunked or not according to size of body)
        Throws:
        PausableHttpPostRequestEncoder.ErrorDataEncoderException - if the encoding is in error or if the finalize were already done
      • isChunked

        public boolean isChunked()
        Returns:
        True if the request is by Chunk
      • close

        public void close()
                   throws Exception
        Specified by:
        close in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
        Throws:
        Exception
      • readChunk

        @Deprecated
        public io.netty.handler.codec.http.HttpContent readChunk​(io.netty.channel.ChannelHandlerContext ctx)
                                                          throws Exception
        Deprecated.
        Specified by:
        readChunk in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
        Throws:
        Exception
      • readChunk

        public io.netty.handler.codec.http.HttpContent readChunk​(io.netty.buffer.ByteBufAllocator allocator)
                                                          throws Exception
        Returns the next available HttpChunk. The caller is responsible to test if this chunk is the last one (isLast()), in order to stop calling this getMethod.
        Specified by:
        readChunk in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
        Returns:
        the next available HttpChunk
        Throws:
        PausableHttpPostRequestEncoder.ErrorDataEncoderException - if the encoding is in error
        Exception
      • isEndOfInput

        public boolean isEndOfInput()
        Specified by:
        isEndOfInput in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
      • length

        public long length()
        Specified by:
        length in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>
      • progress

        public long progress()
        Specified by:
        progress in interface io.netty.handler.stream.ChunkedInput<io.netty.handler.codec.http.HttpContent>