-
Notifications
You must be signed in to change notification settings - Fork 278
2.6 jetty http2 http3 #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
2.6 jetty http2 http3 #1457
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7d30753
add support of Http2 and Http3 protocols
f0980a5
Eclipse format
6f7a9b9
Taken into account PR review comment
92ad326
Add support of HTTP3 server side
12a37b8
Fixed TUs
6668def
Format code
ce0c1cc
Fixed TUs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| /** | ||
| * Copyright 2005-2024 Qlik | ||
| * | ||
| * <p> | ||
| * The contents of this file is subject to the terms of the Apache 2.0 open | ||
| * source license available at http://www.opensource.org/licenses/apache-2.0 | ||
| * | ||
| * <p> | ||
| * Restlet is a registered trademark of QlikTech International AB. | ||
| */ | ||
|
|
||
| package org.restlet.ext.jetty; | ||
|
|
||
| import java.util.logging.Level; | ||
|
|
||
| import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; | ||
| import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; | ||
| import org.eclipse.jetty.server.AbstractConnectionFactory; | ||
| import org.eclipse.jetty.server.ConnectionFactory; | ||
| import org.eclipse.jetty.server.HttpConfiguration; | ||
|
|
@@ -21,6 +21,11 @@ | |
| import org.restlet.engine.ssl.DefaultSslContextFactory; | ||
| import org.restlet.ext.jetty.internal.RestletSslContextFactoryServer; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.logging.Level; | ||
|
|
||
| /** | ||
| * Jetty HTTPS server connector. Here is the list of additional parameters that | ||
| * are supported. They should be set in the Server's context before it is | ||
|
|
@@ -41,10 +46,16 @@ | |
| * parameter, or an instance as an attribute for a more complete and flexible | ||
| * SSL context setting</td> | ||
| * </tr> | ||
| * <tr> | ||
| * <td>http.transport.protocols</td> | ||
| * <td>string</td> | ||
| * <td>http1</td> | ||
|
||
| * <td>Coma separated and sorted list of supported protocols. Values: http1, http2, http3.</td> | ||
| * </tr> | ||
| * </table> | ||
| * For the default SSL parameters see the Javadocs of the | ||
| * {@link DefaultSslContextFactory} class. | ||
| * | ||
| * | ||
| * @see <a href= | ||
| * "https://jetty.org/docs/jetty/12/operations-guide/keystore/index.html">How | ||
| * to configure SSL for Jetty</a> | ||
|
|
@@ -55,7 +66,7 @@ public class HttpsServerHelper extends JettyServerHelper { | |
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * | ||
| * @param server The server to help. | ||
| */ | ||
| public HttpsServerHelper(Server server) { | ||
|
|
@@ -64,21 +75,50 @@ public HttpsServerHelper(Server server) { | |
| } | ||
|
|
||
| @Override | ||
| protected ConnectionFactory[] createConnectionFactories( | ||
| HttpConfiguration configuration) { | ||
| protected ConnectionFactory[] createConnectionFactories(HttpConfiguration configuration) { | ||
| ConnectionFactory[] result; | ||
|
|
||
| try { | ||
| final List<ConnectionFactory> connectionFactories = new ArrayList<>(); | ||
|
|
||
| for (String httpTransportProtocolAsString : getHttpTransportProtocols()) { | ||
| switch (httpTransportProtocolAsString) { | ||
| case "http1": | ||
| connectionFactories.add(new HttpConnectionFactory(configuration)); | ||
| break; | ||
| case "http2": | ||
| connectionFactories.add(new ALPNServerConnectionFactory()); | ||
| connectionFactories.add(new HTTP2ServerConnectionFactory(configuration)); | ||
| break; | ||
| default: | ||
| final String errorMessage = String.format("'%s' is not one of the supported value: [http1, http2]", httpTransportProtocolAsString); | ||
| throw new IllegalArgumentException(errorMessage); | ||
| } | ||
| } | ||
|
|
||
| SslContextFactory.Server sslContextFactory = new RestletSslContextFactoryServer( | ||
| org.restlet.engine.ssl.SslUtils.getSslContextFactory(this)); | ||
| result = AbstractConnectionFactory.getFactories(sslContextFactory, | ||
| new HttpConnectionFactory(configuration)); | ||
|
|
||
| result = AbstractConnectionFactory.getFactories(sslContextFactory, connectionFactories.toArray(new ConnectionFactory[0])); | ||
| } catch (RuntimeException e) { | ||
| getLogger().log(Level.WARNING, "Unable to create the Jetty SSL context factory", e); | ||
| throw e; | ||
| } catch (Exception e) { | ||
| result = null; | ||
| getLogger().log(Level.WARNING, | ||
| "Unable to create the Jetty SSL context factory", e); | ||
| getLogger().log(Level.WARNING, "Unable to create the Jetty SSL context factory", e); | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Supported HTTP transport protocol. Defaults to http1. | ||
| * | ||
| * @return Supported HTTP transport protocol. | ||
| */ | ||
| public List<String> getHttpTransportProtocols() { | ||
| String httpTransportProtocolsAsString = getHelpedParameters().getFirstValue("http.transport.protocols", "http1"); | ||
| return Arrays.stream(httpTransportProtocolsAsString.split(",")) | ||
| .toList(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thboileau Could we use "HTTP1_1" and "HTTP2" for consistency with the protocol version and client-side parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, thanks