Class DefaultH2RequestConverter

java.lang.Object
org.apache.hc.core5.http2.impl.DefaultH2RequestConverter
All Implemented Interfaces:
H2MessageConverter<HttpRequest>

public final class DefaultH2RequestConverter extends Object implements H2MessageConverter<HttpRequest>
HTTP/2 request converter.
Since:
5.0
  • Field Details

  • Constructor Details

    • DefaultH2RequestConverter

      public DefaultH2RequestConverter()
  • Method Details

    • convert

      public HttpRequest convert(List<Header> headers) throws HttpException
      Description copied from interface: H2MessageConverter
      Converts given list of HTTP/2 headers to a HttpMessage.
      Specified by:
      convert in interface H2MessageConverter<HttpRequest>
      Parameters:
      headers - list of HTTP/2 headers
      Returns:
      HTTP message
      Throws:
      HttpException - in case of HTTP protocol violation
    • convert

      public List<Header> convert(HttpRequest message) throws HttpException
      Description copied from interface: H2MessageConverter
      Converts given HttpMessage to a list of HTTP/2 headers.
      Specified by:
      convert in interface H2MessageConverter<HttpRequest>
      Parameters:
      message - HTTP message
      Returns:
      list of HTTP/2 headers
      Throws:
      HttpException - in case of HTTP protocol violation
    • validatePathPseudoHeader

      private void validatePathPseudoHeader(String method, String scheme, String path) throws ProtocolException
      Validates the :path pseudo-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 :path pseudo-header field must not be empty.
      • OPTIONS Method: If the HTTP method is OPTIONS and the URI does not contain a path component, the :path pseudo-header field must have a value of '*'.
      • Path Starting with '/': For 'http' or 'https' URIs, the :path pseudo-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 :path pseudo-header field.
      Throws:
      ProtocolException - if any of the validations fail.