Class HttpConversionUtil


  • @UnstableApi
    public final class HttpConversionUtil
    extends Object
    Provides utility methods and constants for the HTTP/2 to HTTP conversion
    • Method Detail

      • toHttpRequest

        public static HttpRequest toHttpRequest​(int streamId,
                                                Http2Headers http2Headers,
                                                boolean validateHttpHeaders)
                                         throws Http2Exception
        Create a new object to contain the request data.
        Parameters:
        streamId - The stream associated with the request
        http2Headers - The initial set of HTTP/2 headers to create the request with
        validateHttpHeaders -
        • true to validate HTTP headers in the http-codec
        • false not to validate HTTP headers in the http-codec
        Returns:
        A new request object which represents headers for a chunked request
        Throws:
        Http2Exception - see addHttp2ToHttpHeaders(int, Http2Headers, FullHttpMessage, boolean)
      • addHttp2ToHttpHeaders

        public static void addHttp2ToHttpHeaders​(int streamId,
                                                 Http2Headers inputHeaders,
                                                 FullHttpMessage destinationMessage,
                                                 boolean addToTrailer)
                                          throws Http2Exception
        Translate and add HTTP/2 headers to HTTP/1.x headers.
        Parameters:
        streamId - The stream associated with sourceHeaders.
        inputHeaders - The HTTP/2 headers to convert.
        destinationMessage - The object which will contain the resulting HTTP/1.x headers.
        addToTrailer - true to add to trailing headers. false to add to initial headers.
        Throws:
        Http2Exception - If not all HTTP/2 headers can be translated to HTTP/1.x.
        See Also:
        addHttp2ToHttpHeaders(int, Http2Headers, HttpHeaders, HttpVersion, boolean, boolean)
      • addHttp2ToHttpHeaders

        public static void addHttp2ToHttpHeaders​(int streamId,
                                                 Http2Headers inputHeaders,
                                                 HttpHeaders outputHeaders,
                                                 HttpVersion httpVersion,
                                                 boolean isTrailer,
                                                 boolean isRequest)
                                          throws Http2Exception
        Translate and add HTTP/2 headers to HTTP/1.x headers.
        Parameters:
        streamId - The stream associated with sourceHeaders.
        inputHeaders - The HTTP/2 headers to convert.
        outputHeaders - The object which will contain the resulting HTTP/1.x headers..
        httpVersion - What HTTP/1.x version outputHeaders should be treated as when doing the conversion.
        isTrailer - true if outputHeaders should be treated as trailing headers. false otherwise.
        isRequest - true if the outputHeaders will be used in a request message. false for response message.
        Throws:
        Http2Exception - If not all HTTP/2 headers can be translated to HTTP/1.x.