Class QuarkusMultipartResponseDecoder


  • public class QuarkusMultipartResponseDecoder
    extends Object
    This decoder will decode response body. You MUST call destroy() after completion to release all resources. Decoder for Multipart responses based on Netty's HttpPostMultipartRequestDecoder
    • Constructor Detail

      • QuarkusMultipartResponseDecoder

        public QuarkusMultipartResponseDecoder​(io.vertx.core.http.HttpClientResponse response)
        Parameters:
        response - the request to decode
        Throws:
        NullPointerException - for request
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errors
      • QuarkusMultipartResponseDecoder

        public QuarkusMultipartResponseDecoder​(QuarkusMultipartResponseDataFactory factory,
                                               io.vertx.core.http.HttpClientResponse response)
        Parameters:
        factory - the factory used to create InterfaceHttpData
        response - the request to decode
        Throws:
        NullPointerException - for request or factory
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errors
      • QuarkusMultipartResponseDecoder

        public QuarkusMultipartResponseDecoder​(QuarkusMultipartResponseDataFactory factory,
                                               io.vertx.core.http.HttpClientResponse response,
                                               Charset charset)
        Parameters:
        factory - the factory used to create InterfaceHttpData
        response - the request to decode
        charset - the charset to use as default
        Throws:
        NullPointerException - for request or charset or factory
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errors
    • Method Detail

      • isMultipart

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

        public void setDiscardThreshold​(int discardThreshold)
        Set the amount of bytes after which read bytes in the buffer should be discarded. Setting this lower gives lower memory usage but with the overhead of more memory copies. Use 0 to disable it.
      • getDiscardThreshold

        public int getDiscardThreshold()
        Return the threshold in bytes after which read data in the buffer should be discarded.
      • getBodyHttpDatas

        public List<io.netty.handler.codec.http.multipart.InterfaceHttpData> getBodyHttpDatas()
        This getMethod returns a List of all HttpDatas from body.
        If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.
        Returns:
        the list of HttpDatas from Body part for POST getMethod
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks
      • getBodyHttpDatas

        public List<io.netty.handler.codec.http.multipart.InterfaceHttpData> getBodyHttpDatas​(String name)
        This getMethod returns a List of all HttpDatas with the given name from body.
        If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.
        Returns:
        All Body HttpDatas with the given name (ignore case)
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunks
      • getBodyHttpData

        public io.netty.handler.codec.http.multipart.InterfaceHttpData getBodyHttpData​(String name)
        This getMethod returns the first InterfaceHttpData with the given name from body.
        If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.
        Returns:
        The first Body InterfaceHttpData with the given name (ignore case)
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunks
      • offer

        public QuarkusMultipartResponseDecoder offer​(io.netty.handler.codec.http.HttpContent content)
        Initialized the internals from a new chunk
        Parameters:
        content - the new received chunk
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException - if there is a problem with the charset decoding or other errors
      • hasNext

        public boolean hasNext()
        True if at current getStatus, there is an available decoded InterfaceHttpData from the Body. This getMethod works for chunked and not chunked request.
        Returns:
        True if at current getStatus, there is a decoded InterfaceHttpData
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException - No more data will be available
      • next

        public io.netty.handler.codec.http.multipart.InterfaceHttpData next()
        Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData. A subsequent call to offer(httpChunk) could enable more data. Be sure to call ReferenceCounted.release() after you are done with processing to make sure to not leak any resources
        Returns:
        the next available InterfaceHttpData or null if none
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException - No more data will be available
      • currentPartialHttpData

        public io.netty.handler.codec.http.multipart.InterfaceHttpData currentPartialHttpData()
      • addHttpData

        protected void addHttpData​(io.netty.handler.codec.http.multipart.InterfaceHttpData data)
        Utility function to add a new decoded data
      • getFileUpload

        protected io.netty.handler.codec.http.multipart.InterfaceHttpData getFileUpload​(String delimiter)
        Get the FileUpload (new one or current one)
        Parameters:
        delimiter - the delimiter to use
        Returns:
        the InterfaceHttpData if any
        Throws:
        io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException - on decoder error
      • destroy

        public void destroy()
        Destroy the QuarkusMultipartResponseDecoder and release all it resources. After this method was called it is not possible to operate on it anymore.
      • cleanFiles

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

        public void removeHttpDataFromClean​(io.netty.handler.codec.http.multipart.InterfaceHttpData data)
        Remove the given FileUpload from the list of FileUploads to clean