HTTP/2 and HTTP/3 Support


The HTTP component and the other HTTP-based components (e.g., REST, SOAP, WebUpload, and WebDAV) support HTTP/1.0, HTTP/1.1, HTTP/2, and HTTP/3. HTTP/1.1 is used by default, and other versions are enabled by setting the HTTPVersion property. Requests are made in the same way regardless of the version, so no other changes to the code are needed.

Enabling HTTP/2

To use HTTP/2, set the HTTPVersion property to 2.0:

HTTP http = new HTTP();
http.HTTPVersion = "2.0";
http.Get("https://www.example.com/");

// Check which version of HTTP was used for the request.
Console.WriteLine(http.Config("NegotiatedHTTPVersion"));

HTTP/2 requires a secure (TLS) connection, and the version is negotiated with the server during the TLS handshake (using ALPN). Requests to plaintext (http://) URLs fail with an error when HTTPVersion is 2.0.

If the server does not support HTTP/2, the component automatically uses HTTP/1.1 instead. The version that was used can be checked using the NegotiatedHTTPVersion configuration setting after the request is complete. To make the request fail with an error instead of falling back to HTTP/1.1, set the AllowHTTPFallback configuration setting to false.

Enabling HTTP/3

To use HTTP/3, set the HTTPVersion property to 3.0:

HTTP http = new HTTP();
http.HTTPVersion = "3.0";
http.Get("https://www.example.com/");

HTTP/3 also requires a secure connection, and requests to plaintext URLs fail with an error. HTTP/3 runs over QUIC, which uses UDP instead of TCP, so outgoing UDP traffic to the server (usually on port 443) must be allowed by any firewalls between the application and the server. When HTTP/3 is used, the internal TLS implementation of the components is always used.

Other Components

Most HTTP-based components (e.g., REST, SOAP, WebUpload, WebForm, WebDAV, OData, and RSS) have an HTTPVersion property, which is used in the same way. For components that use HTTP internally but do not have the property, set the HTTPVersion configuration setting instead:

component.Config("HTTPVersion=2.0");

Platform Support

Version Supported Editions
HTTP/2 All editions and platforms. On Windows versions earlier than Windows 8.1 and Windows Server 2012 R2, which do not support ALPN, the internal TLS implementation is used automatically.
HTTP/3 .NET and Java editions only.

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.