Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
cfg, scheme.toString(), reqTarget);
// Do not accept unsupported methods.
final HttpMethod method = headers.method();
switch (method) {
case CONNECT:
case UNKNOWN:
fail(id, headers, HttpStatus.METHOD_NOT_ALLOWED, "Unsupported method", null);
return;
if (method == HttpMethod.CONNECT) {
fail(id, headers, HttpStatus.METHOD_NOT_ALLOWED, "Unsupported method", null);
return;
}

// Do not accept the request path '*' for a non-OPTIONS request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,13 @@ public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
scheme.toString(), cfg, reqTarget);

// Reject a request with an unsupported method.
switch (method) {
case CONNECT:
// Accept a CONNECT request only when it has a :protocol header, as defined in:
// https://datatracker.ietf.org/doc/html/rfc8441#section-4
if (!nettyHeaders.contains(HttpHeaderNames.PROTOCOL)) {
writeUnsupportedMethodResponse(streamId, headers);
return;
}
break;
case UNKNOWN:
if (method == HttpMethod.CONNECT) {
// Accept a CONNECT request only when it has a :protocol header, as defined in:
// https://datatracker.ietf.org/doc/html/rfc8441#section-4
if (!nettyHeaders.contains(HttpHeaderNames.PROTOCOL)) {
writeUnsupportedMethodResponse(streamId, headers);
return;
}
}

// Do not accept the request path '*' for a non-OPTIONS request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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);
Expand Down
Loading