Netty should be able to handle any valid URI. But currently io.netty.handler.codec.http2.HttpConversionUtil is relying on java.net.URI class, which supports https://datatracker.ietf.org/doc/rfc2396/, but does not support https://datatracker.ietf.org/doc/rfc3986/ . So, some legal characters in the URI path, e.g. {, are breaking the conversion.
Expected behavior
Any HTTP header with rfc3986-compliant path (and probably non-compiant too) should be convertable to Http2Headers
Actual behavior
IllegalArgumentException is rethrown caused by an exception in java.net.URI:
java.lang.IllegalArgumentException: Illegal character in query at index 63: https://bh.contextweb.com/bh/rtset?pid=558355&ev=1&us_privacy=${us_privacy}
at java.base/java.net.URI.create(URI.java:906)
at io.netty.handler.codec.http2.HttpConversionUtil.toHttp2Headers(HttpConversionUtil.java:441)
...
Caused by: java.net.URISyntaxException: Illegal character in query at index 63: https://bh.contextweb.com/bh/rtset?pid=558355&ev=1&us_privacy=${us_privacy}
at java.base/java.net.URI$Parser.fail(URI.java:2976)
at java.base/java.net.URI$Parser.checkChars(URI.java:3147)
at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3235)
at java.base/java.net.URI$Parser.parse(URI.java:3177)
at java.base/java.net.URI.<init>(URI.java:623)
at java.base/java.net.URI.create(URI.java:904)
... 71 more
Steps to reproduce
Use any code flow that converts HttpMessage object to Http2Headers using HttpConversionUtil with a URL with characters not supported by rfc2396.
Minimal yet complete reproducer code (or URL to code)
public class HttpConversionUtilTest {
@Test
void testToHttp2HeadersFromHttpRequest() {
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "https://bh.contextweb.com/bh/rtset?pid=558355&ev=1&us_privacy=${us_privacy}");
Http2Headers http2Headers = HttpConversionUtil.toHttp2Headers(httpRequest, true);
assertEquals("/bh/rtset?pid=558355&ev=1&us_privacy=${us_privacy}", http2Headers.path().toString());
}
}
Netty version
4.1.115
JVM version (e.g. java -version)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
OS version (e.g. uname -a)
Darwin us-m-ccloud01 22.6.0 Darwin Kernel Version 22.6.0: Fri Nov 15 17:21:49 PST 2024; root:xnu-8796.141.3.709.7~2/RELEASE_X86_64 x86_64
Netty should be able to handle any valid URI. But currently
io.netty.handler.codec.http2.HttpConversionUtilis relying onjava.net.URIclass, which supports https://datatracker.ietf.org/doc/rfc2396/, but does not support https://datatracker.ietf.org/doc/rfc3986/ . So, some legal characters in the URI path, e.g.{, are breaking the conversion.Expected behavior
Any HTTP header with rfc3986-compliant path (and probably non-compiant too) should be convertable to Http2Headers
Actual behavior
IllegalArgumentException is rethrown caused by an exception in java.net.URI:
Steps to reproduce
Use any code flow that converts HttpMessage object to Http2Headers using HttpConversionUtil with a URL with characters not supported by rfc2396.
Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.115
JVM version (e.g.
java -version)OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
OS version (e.g.
uname -a)Darwin us-m-ccloud01 22.6.0 Darwin Kernel Version 22.6.0: Fri Nov 15 17:21:49 PST 2024; root:xnu-8796.141.3.709.7~2/RELEASE_X86_64 x86_64