Package org.apache.hc.core5.http2.impl
Class DefaultH2RequestConverter
- java.lang.Object
-
- org.apache.hc.core5.http2.impl.DefaultH2RequestConverter
-
- All Implemented Interfaces:
H2MessageConverter<HttpRequest>
public final class DefaultH2RequestConverter extends java.lang.Object implements H2MessageConverter<HttpRequest>
HTTP/2 request converter.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultH2RequestConverterINSTANCE
-
Constructor Summary
Constructors Constructor Description DefaultH2RequestConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpRequestconvert(java.util.List<Header> headers)Converts given list of HTTP/2 headers to aHttpMessage.java.util.List<Header>convert(HttpRequest message)Converts givenHttpMessageto a list of HTTP/2 headers.private voidvalidatePathPseudoHeader(java.lang.String method, java.lang.String scheme, java.lang.String path)Validates the:pathpseudo-header field based on the provided HTTP method and scheme.
-
-
-
Field Detail
-
INSTANCE
public static final DefaultH2RequestConverter INSTANCE
-
-
Method Detail
-
convert
public HttpRequest convert(java.util.List<Header> headers) throws HttpException
Description copied from interface:H2MessageConverterConverts given list of HTTP/2 headers to aHttpMessage.- Specified by:
convertin interfaceH2MessageConverter<HttpRequest>- Parameters:
headers- list of HTTP/2 headers- Returns:
- HTTP message
- Throws:
HttpException- in case of HTTP protocol violation
-
convert
public java.util.List<Header> convert(HttpRequest message) throws HttpException
Description copied from interface:H2MessageConverterConverts givenHttpMessageto a list of HTTP/2 headers.- Specified by:
convertin interfaceH2MessageConverter<HttpRequest>- Parameters:
message- HTTP message- Returns:
- list of HTTP/2 headers
- Throws:
HttpException- in case of HTTP protocol violation
-
validatePathPseudoHeader
private void validatePathPseudoHeader(java.lang.String method, java.lang.String scheme, java.lang.String path) throws ProtocolExceptionValidates the:pathpseudo-header field based on the provided HTTP method and scheme.This method performs the following validations:
- Non-Empty Path: For 'http' or 'https' URIs, the
:pathpseudo-header field must not be empty. - OPTIONS Method: If the HTTP method is OPTIONS and the URI does not contain a path component,
the
:pathpseudo-header field must have a value of '*'. - Path Starting with '/': For 'http' or 'https' URIs, the
:pathpseudo-header field must either start with '/' or be '*'.
- Parameters:
method- The HTTP method of the request, e.g., GET, POST, OPTIONS, etc.scheme- The scheme of the request, e.g., http or https.path- The value of the:pathpseudo-header field.- Throws:
ProtocolException- if any of the validations fail.
- Non-Empty Path: For 'http' or 'https' URIs, the
-
-