-
Notifications
You must be signed in to change notification settings - Fork 973
Do not reject UNKNOWN HttpMethod #6172
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
base: main
Are you sure you want to change the base?
Changes from all commits
36eb775
bd625d3
7b3c32d
675bedc
ad3f977
59b48a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |
| import java.security.cert.X509Certificate; | ||
| import java.time.Duration; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
@@ -73,6 +74,7 @@ | |
| import com.linecorp.armeria.common.Flags; | ||
| import com.linecorp.armeria.common.Http1HeaderNaming; | ||
| import com.linecorp.armeria.common.HttpHeaderNames; | ||
| import com.linecorp.armeria.common.HttpMethod; | ||
| import com.linecorp.armeria.common.HttpRequest; | ||
| import com.linecorp.armeria.common.HttpResponse; | ||
| import com.linecorp.armeria.common.Request; | ||
|
|
@@ -229,6 +231,7 @@ public final class ServerBuilder implements TlsSetters, ServiceConfigsBuilder<Se | |
| private boolean enableServerHeader = true; | ||
| private boolean enableDateHeader = true; | ||
| private Http1HeaderNaming http1HeaderNaming = Http1HeaderNaming.ofDefault(); | ||
| private final List<String> additionalAllowedHttpMethods = new ArrayList<>(); | ||
| @Nullable | ||
| private DependencyInjector dependencyInjector; | ||
| private Function<? super String, String> absoluteUriTransformer = Function.identity(); | ||
|
|
@@ -2220,6 +2223,17 @@ public ServerBuilder http1HeaderNaming(Http1HeaderNaming http1HeaderNaming) { | |
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Adds additional allowed HTTP methods to the default set of allowed {@link HttpMethod}s. | ||
| * | ||
| * @param additionalAllowedHttpMethods the additional allowed HTTP methods | ||
| */ | ||
| public ServerBuilder additionalAllowedHttpMethods(String... additionalAllowedHttpMethods) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional) for consistency with other APIs, it may be worth adding a |
||
| requireNonNull(additionalAllowedHttpMethods, "additionalAllowedHttpMethods"); | ||
| this.additionalAllowedHttpMethods.addAll(Arrays.asList(additionalAllowedHttpMethods)); | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the interval between reporting exceptions which is not logged | ||
| * by any decorators or services such as {@link LoggingService}. | ||
|
|
@@ -2427,7 +2441,7 @@ ports, setSslContextIfAbsent(defaultVirtualHost, defaultSslContext), | |
| childChannelPipelineCustomizer, | ||
| clientAddressSources, clientAddressTrustedProxyFilter, clientAddressFilter, clientAddressMapper, | ||
| enableServerHeader, enableDateHeader, errorHandler, sslContexts, | ||
| http1HeaderNaming, dependencyInjector, absoluteUriTransformer, | ||
| http1HeaderNaming, additionalAllowedHttpMethods, dependencyInjector, absoluteUriTransformer, | ||
| unloggedExceptionsReportIntervalMillis, ImmutableList.copyOf(shutdownSupports)); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -532,8 +532,7 @@ private Request convertRequest(ServiceRequestContext ctx, String mappedPath, Agg | |
| coyoteReq.protocol().setString(ctx.sessionProtocol().isMultiplex() ? "HTTP/2.0" : "HTTP/1.1"); | ||
|
|
||
| // Set the method. | ||
| final HttpMethod method = req.method(); | ||
| coyoteReq.method().setString(method.name()); | ||
| coyoteReq.method().setString(req.headers().get(HttpHeaderNames.METHOD)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a integration test which validates the server can successfully process the custom http method?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I think it's fine to support just tomcat for now, and add support for jetty later if needed/reported |
||
|
|
||
| // Set the request URI. | ||
| final byte[] uriBytes = mappedPath.getBytes(StandardCharsets.US_ASCII); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.