-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Support for HTTP/3 (server side) #20017
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-classes-quic-4.2.9.Final.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8b441d8465077c1ac1ed57bad3f087bc2a84e994 |
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-http3-4.2.9.Final.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| e8a593762196738c0265259e5728a275e2d8f1ea | ||
reta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1 change: 1 addition & 0 deletions
1
...les/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final-linux-aarch_64.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 87ce82aa487b3701a83312b748d2d311b58bbe68 |
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final-linux-x86_64.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3f0ab9d43f00c8a02ba22702aff482f598863642 |
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final-osx-aarch_64.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7725db063980a53420afbced5fb39dbd0eebbd8a |
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final-osx-x86_64.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 53eee547f8731254084274d31b82171c51d509fa |
1 change: 1 addition & 0 deletions
1
...les/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final-windows-x86_64.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 6873dd577760b80b345fa5ab7dfe589ed9c1bbc3 |
1 change: 1 addition & 0 deletions
1
modules/transport-netty4/licenses/netty-codec-native-quic-4.2.9.Final.jar.sha1
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 97fda97b8df8f3e8fefa50336e108756b76f8b77 | ||
reta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
75 changes: 75 additions & 0 deletions
75
...t-netty4/src/main/java/org/opensearch/http/netty4/Netty4CompositeHttpServerTransport.java
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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.http.netty4; | ||
|
|
||
| import org.opensearch.common.lifecycle.AbstractLifecycleComponent; | ||
| import org.opensearch.common.util.io.IOUtils; | ||
| import org.opensearch.core.common.transport.BoundTransportAddress; | ||
| import org.opensearch.http.AbstractHttpServerTransport; | ||
| import org.opensearch.http.HttpInfo; | ||
| import org.opensearch.http.HttpServerTransport; | ||
| import org.opensearch.http.HttpStats; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class Netty4CompositeHttpServerTransport extends AbstractLifecycleComponent implements HttpServerTransport { | ||
| private final AbstractHttpServerTransport[] transports; | ||
|
|
||
| public Netty4CompositeHttpServerTransport(AbstractHttpServerTransport... transports) { | ||
| if (transports == null || transports.length == 0) { | ||
| throw new IllegalArgumentException("At least one transport must be provided"); | ||
| } | ||
|
|
||
| this.transports = transports; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| public BoundTransportAddress boundAddress() { | ||
| return transports[0].boundAddress(); /* both transports bind to the same port but different protocol */ | ||
| } | ||
|
|
||
| @Override | ||
| public HttpInfo info() { | ||
| return transports[0].info(); | ||
| } | ||
|
|
||
| @Override | ||
| public HttpStats stats() { | ||
| long serverOpen = 0L, totalOpen = 0L; | ||
|
|
||
| for (AbstractHttpServerTransport transport : transports) { | ||
| final HttpStats stats = transport.stats(); | ||
| serverOpen += stats.getServerOpen(); | ||
| totalOpen += stats.getTotalOpen(); | ||
| } | ||
|
|
||
| return new HttpStats.Builder().serverOpen(serverOpen).totalOpen(totalOpen).build(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void doStart() { | ||
| for (AbstractHttpServerTransport transport : transports) { | ||
| transport.start(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void doStop() { | ||
| for (AbstractHttpServerTransport transport : transports) { | ||
| transport.stop(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void doClose() throws IOException { | ||
| for (AbstractHttpServerTransport transport : transports) { | ||
| IOUtils.closeWhileHandlingException(transport); | ||
| } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
81 changes: 81 additions & 0 deletions
81
.../transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4Http3RequestCreator.java
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /* | ||
| * Modifications Copyright OpenSearch Contributors. See | ||
| * GitHub history for details. | ||
| */ | ||
cwperks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| package org.opensearch.http.netty4; | ||
|
|
||
| import org.opensearch.ExceptionsHelper; | ||
| import org.opensearch.core.common.unit.ByteSizeValue; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import io.netty.channel.ChannelHandler; | ||
| import io.netty.channel.ChannelHandlerContext; | ||
| import io.netty.handler.codec.MessageToMessageDecoder; | ||
| import io.netty.handler.codec.http.FullHttpRequest; | ||
| import io.netty.handler.codec.http.TooLongHttpLineException; | ||
|
|
||
| @ChannelHandler.Sharable | ||
cwperks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class Netty4Http3RequestCreator extends MessageToMessageDecoder<FullHttpRequest> { | ||
| private final ByteSizeValue maxInitialLineLength; | ||
|
|
||
| Netty4Http3RequestCreator(ByteSizeValue maxInitialLineLength) { | ||
| this.maxInitialLineLength = maxInitialLineLength; | ||
| } | ||
|
|
||
| @Override | ||
| protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) { | ||
| if (msg.decoderResult().isFailure()) { | ||
| final Throwable cause = msg.decoderResult().cause(); | ||
| final Exception nonError; | ||
| if (cause instanceof Error) { | ||
| ExceptionsHelper.maybeDieOnAnotherThread(cause); | ||
| nonError = new Exception(cause); | ||
| } else { | ||
| nonError = (Exception) cause; | ||
| } | ||
| out.add(new Netty4HttpRequest(msg.retain(), nonError)); | ||
reta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else { | ||
| // The HTTP/3 implementation in Netty does not validate Request URI length, manually | ||
| // applying the validation rules here. | ||
| if (msg.uri().length() > maxInitialLineLength.bytesAsInt()) { | ||
| out.add( | ||
| new Netty4HttpRequest( | ||
| msg.retain(), | ||
| new TooLongHttpLineException("An HTTP line is larger than " + maxInitialLineLength.bytesAsInt() + " bytes.") | ||
| ) | ||
| ); | ||
| } else { | ||
| out.add(new Netty4HttpRequest(msg.retain())); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.