@UnstableApi public final class HttpConversionUtil extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
HttpConversionUtil.ExtensionHeaderNames
Provides the HTTP header extensions used to carry HTTP/2 information in HTTP objects
|
private static class |
HttpConversionUtil.Http2ToHttpHeaderTranslator
Utility which translates HTTP/2 headers to HTTP/1 headers.
|
Modifier and Type | Field and Description |
---|---|
private static AsciiString |
EMPTY_REQUEST_PATH
rfc7540, 8.1.2.3 states the path must not
be empty, and instead should be
/ . |
private static CharSequenceMap<AsciiString> |
HTTP_TO_HTTP2_HEADER_BLACKLIST
The set of headers that should not be directly copied when converting headers from HTTP to HTTP/2.
|
static HttpMethod |
OUT_OF_MESSAGE_SEQUENCE_METHOD
This will be the method used for
HttpRequest objects generated out of the HTTP message flow defined in HTTP/2 Spec Message Flow |
static java.lang.String |
OUT_OF_MESSAGE_SEQUENCE_PATH
This will be the path used for
HttpRequest objects generated out of the HTTP message flow defined in HTTP/2 Spec Message Flow |
static HttpResponseStatus |
OUT_OF_MESSAGE_SEQUENCE_RETURN_CODE
This will be the status code used for
HttpResponse objects generated out of the HTTP message flow defined
in HTTP/2 Spec Message Flow |
Modifier | Constructor and Description |
---|---|
private |
HttpConversionUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addHttp2ToHttpHeaders(int streamId,
Http2Headers sourceHeaders,
FullHttpMessage destinationMessage,
boolean addToTrailer)
Translate and add HTTP/2 headers to HTTP/1.x headers.
|
static void |
addHttp2ToHttpHeaders(int streamId,
Http2Headers inputHeaders,
HttpHeaders outputHeaders,
HttpVersion httpVersion,
boolean isTrailer,
boolean isRequest)
Translate and add HTTP/2 headers to HTTP/1.x headers.
|
static HttpResponseStatus |
parseStatus(java.lang.CharSequence status)
Apply HTTP/2 rules while translating status code to
HttpResponseStatus |
private static void |
setHttp2Authority(java.lang.String authority,
Http2Headers out) |
private static void |
setHttp2Scheme(HttpHeaders in,
java.net.URI uri,
Http2Headers out) |
static FullHttpRequest |
toFullHttpRequest(int streamId,
Http2Headers http2Headers,
ByteBufAllocator alloc,
boolean validateHttpHeaders)
Create a new object to contain the request data
|
static Http2Headers |
toHttp2Headers(HttpHeaders inHeaders,
boolean validateHeaders) |
static void |
toHttp2Headers(HttpHeaders inHeaders,
Http2Headers out) |
static Http2Headers |
toHttp2Headers(HttpMessage in,
boolean validateHeaders)
Converts the given HTTP/1.x headers into HTTP/2 headers.
|
private static AsciiString |
toHttp2Path(java.net.URI uri)
Generate a HTTP/2 {code :path} from a URI in accordance with
rfc7230, 5.3.
|
static HttpRequest |
toHttpRequest(int streamId,
Http2Headers http2Headers,
boolean validateHttpHeaders)
Create a new object to contain the request data.
|
static FullHttpResponse |
toHttpResponse(int streamId,
Http2Headers http2Headers,
ByteBufAllocator alloc,
boolean validateHttpHeaders)
Create a new object to contain the response data
|
private static final CharSequenceMap<AsciiString> HTTP_TO_HTTP2_HEADER_BLACKLIST
public static final HttpMethod OUT_OF_MESSAGE_SEQUENCE_METHOD
HttpRequest
objects generated out of the HTTP message flow defined in HTTP/2 Spec Message Flowpublic static final java.lang.String OUT_OF_MESSAGE_SEQUENCE_PATH
HttpRequest
objects generated out of the HTTP message flow defined in HTTP/2 Spec Message Flowpublic static final HttpResponseStatus OUT_OF_MESSAGE_SEQUENCE_RETURN_CODE
HttpResponse
objects generated out of the HTTP message flow defined
in HTTP/2 Spec Message Flowprivate static final AsciiString EMPTY_REQUEST_PATH
/
.public static HttpResponseStatus parseStatus(java.lang.CharSequence status) throws Http2Exception
HttpResponseStatus
status
- The status from an HTTP/2 frameHttp2Exception
- If there is a problem translating from HTTP/2 to HTTP/1.xpublic static FullHttpResponse toHttpResponse(int streamId, Http2Headers http2Headers, ByteBufAllocator alloc, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the responsehttp2Headers
- The initial set of HTTP/2 headers to create the response withalloc
- The ByteBufAllocator
to use to generate the content of the messagevalidateHttpHeaders
- true
to validate HTTP headers in the http-codecfalse
not to validate HTTP headers in the http-codecHttp2Exception
- see addHttp2ToHttpHeaders(int, Http2Headers, FullHttpMessage, boolean)
public static FullHttpRequest toFullHttpRequest(int streamId, Http2Headers http2Headers, ByteBufAllocator alloc, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the requesthttp2Headers
- The initial set of HTTP/2 headers to create the request withalloc
- The ByteBufAllocator
to use to generate the content of the messagevalidateHttpHeaders
- true
to validate HTTP headers in the http-codecfalse
not to validate HTTP headers in the http-codecHttp2Exception
- see addHttp2ToHttpHeaders(int, Http2Headers, FullHttpMessage, boolean)
public static HttpRequest toHttpRequest(int streamId, Http2Headers http2Headers, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the requesthttp2Headers
- The initial set of HTTP/2 headers to create the request withvalidateHttpHeaders
- true
to validate HTTP headers in the http-codecfalse
not to validate HTTP headers in the http-codecHttp2Exception
- see addHttp2ToHttpHeaders(int, Http2Headers, FullHttpMessage, boolean)
public static void addHttp2ToHttpHeaders(int streamId, Http2Headers sourceHeaders, FullHttpMessage destinationMessage, boolean addToTrailer) throws Http2Exception
streamId
- The stream associated with sourceHeaders
.sourceHeaders
- 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.Http2Exception
- If not all HTTP/2 headers can be translated to HTTP/1.x.addHttp2ToHttpHeaders(int, Http2Headers, HttpHeaders, HttpVersion, boolean, boolean)
public static void addHttp2ToHttpHeaders(int streamId, Http2Headers inputHeaders, HttpHeaders outputHeaders, HttpVersion httpVersion, boolean isTrailer, boolean isRequest) throws Http2Exception
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.Http2Exception
- If not all HTTP/2 headers can be translated to HTTP/1.x.public static Http2Headers toHttp2Headers(HttpMessage in, boolean validateHeaders)
HOST
header or the
Request-Line
as defined by rfc7230
HttpConversionUtil.ExtensionHeaderNames.PATH
is ignored and instead extracted from the Request-Line
.public static Http2Headers toHttp2Headers(HttpHeaders inHeaders, boolean validateHeaders)
public static void toHttp2Headers(HttpHeaders inHeaders, Http2Headers out)
private static AsciiString toHttp2Path(java.net.URI uri)
private static void setHttp2Authority(java.lang.String authority, Http2Headers out)
private static void setHttp2Scheme(HttpHeaders in, java.net.URI uri, Http2Headers out)