class HttpConversionUtil {

  public static Http2Headers toHttp2Headers(final HttpMessage in, final boolean validateHeaders) {
    final HttpHeaders inHeaders = in.headers();
    final Http2Headers out = new DefaultHttp2Headers(validateHeaders, inHeaders.size());
    if (in instanceof HttpRequest) {
      final HttpRequest request = (HttpRequest) in;
      final URI requestTargetUri = URI.create(request.uri());
      out.path(toHttp2Path(requestTargetUri));
      out.method(request.method().asciiName());
      setHttp2Scheme(inHeaders, requestTargetUri, out);

      if (!isOriginForm(requestTargetUri) && !isAsteriskForm(requestTargetUri)) {
        // Attempt to take from HOST header before taking from the request-line
        final String host = inHeaders.getAsString(HttpHeaderNames.HOST);
        setHttp2Authority(
            (host == null || host.isEmpty()) ? requestTargetUri.getAuthority() : host, out);
      }
    } else if (in instanceof HttpResponse) {
      final HttpResponse response = (HttpResponse) in;
      out.status(response.status().codeAsText());
    }

    // Add the HTTP headers which have not been consumed above
    toHttp2Headers(inHeaders, out);
    return out;
  }

  private  HttpConversionUtil();

}