@UnstableApi public final class HttpConversionUtil extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
HttpConversionUtil.ExtensionHeaderNames
Provides the HTTP header extensions used to carry HTTP/2 information in HTTP objects
|
限定符和类型 | 字段和说明 |
---|---|
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 [RFC 7540], Section 8.1 |
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 [RFC 7540], Section 8.1 |
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 [RFC 7540], Section 8.1 |
限定符和类型 | 方法和说明 |
---|---|
static void |
addHttp2ToHttpHeaders(int streamId,
Http2Headers inputHeaders,
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 |
static FullHttpRequest |
toFullHttpRequest(int streamId,
Http2Headers http2Headers,
ByteBufAllocator alloc,
boolean validateHttpHeaders)
Create a new object to contain the request data
|
static FullHttpRequest |
toFullHttpRequest(int streamId,
Http2Headers http2Headers,
ByteBuf content,
boolean validateHttpHeaders)
Create a new object to contain the request data
|
static FullHttpResponse |
toFullHttpResponse(int streamId,
Http2Headers http2Headers,
ByteBufAllocator alloc,
boolean validateHttpHeaders)
Create a new object to contain the response data
|
static FullHttpResponse |
toFullHttpResponse(int streamId,
Http2Headers http2Headers,
ByteBuf content,
boolean validateHttpHeaders)
Create a new object to contain the response 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.
|
static HttpRequest |
toHttpRequest(int streamId,
Http2Headers http2Headers,
boolean validateHttpHeaders)
Create a new object to contain the request data.
|
static HttpResponse |
toHttpResponse(int streamId,
Http2Headers http2Headers,
boolean validateHttpHeaders)
Create a new object to contain the response data.
|
public static final HttpMethod OUT_OF_MESSAGE_SEQUENCE_METHOD
HttpRequest
objects generated out of the HTTP message flow defined in [RFC 7540], Section 8.1public static final java.lang.String OUT_OF_MESSAGE_SEQUENCE_PATH
HttpRequest
objects generated out of the HTTP message flow defined in [RFC 7540], Section 8.1public static final HttpResponseStatus OUT_OF_MESSAGE_SEQUENCE_RETURN_CODE
HttpResponse
objects generated out of the HTTP message flow defined
in [RFC 7540], Section 8.1public 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 toFullHttpResponse(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 FullHttpResponse toFullHttpResponse(int streamId, Http2Headers http2Headers, ByteBuf content, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the responsehttp2Headers
- The initial set of HTTP/2 headers to create the response withcontent
- ByteBuf
content to put in FullHttpResponse
validateHttpHeaders
- 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 FullHttpRequest toFullHttpRequest(int streamId, Http2Headers http2Headers, ByteBuf content, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the requesthttp2Headers
- The initial set of HTTP/2 headers to create the request withcontent
- ByteBuf
content to put in FullHttpRequest
validateHttpHeaders
- 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 HttpResponse toHttpResponse(int streamId, Http2Headers http2Headers, boolean validateHttpHeaders) throws Http2Exception
streamId
- The stream associated with the responsehttp2Headers
- The initial set of HTTP/2 headers to create the response withvalidateHttpHeaders
- true
to validate HTTP headers in the http-codecfalse
not to validate HTTP headers in the http-codecHttp2Exception
- see addHttp2ToHttpHeaders(int, Http2Headers,
HttpHeaders, HttpVersion, boolean, boolean)
public static void addHttp2ToHttpHeaders(int streamId, Http2Headers inputHeaders, FullHttpMessage destinationMessage, boolean addToTrailer) throws Http2Exception
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.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)