-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
server.max-http-request-header-size doesn't affect Netty server with http2 enabled #36766
Changes from 1 commit
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 |
---|---|---|
|
@@ -64,6 +64,8 @@ public void customize(NettyReactiveWebServerFactory factory) { | |
map.from(nettyProperties::getIdleTimeout).to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout)); | ||
map.from(nettyProperties::getMaxKeepAliveRequests) | ||
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests)); | ||
map.from(this.serverProperties.getMaxHttpRequestHeaderSize()) | ||
.to((maxHttpRequestHeaderSize) -> customizeHttp2MaxHeaderSize(factory, maxHttpRequestHeaderSize.toBytes())); | ||
customizeRequestDecoder(factory, map); | ||
} | ||
|
||
|
@@ -83,25 +85,19 @@ private void customizeConnectionTimeout(NettyReactiveWebServerFactory factory, D | |
private void customizeRequestDecoder(NettyReactiveWebServerFactory factory, PropertyMapper propertyMapper) { | ||
factory.addServerCustomizers((httpServer) -> httpServer.httpRequestDecoder((httpRequestDecoderSpec) -> { | ||
propertyMapper.from(this.serverProperties.getMaxHttpRequestHeaderSize()) | ||
.whenNonNull() | ||
.to((maxHttpRequestHeader) -> httpRequestDecoderSpec | ||
.maxHeaderSize((int) maxHttpRequestHeader.toBytes())); | ||
ServerProperties.Netty nettyProperties = this.serverProperties.getNetty(); | ||
maxChunkSize(propertyMapper, httpRequestDecoderSpec, nettyProperties); | ||
propertyMapper.from(nettyProperties.getMaxInitialLineLength()) | ||
.whenNonNull() | ||
.to((maxInitialLineLength) -> httpRequestDecoderSpec | ||
.maxInitialLineLength((int) maxInitialLineLength.toBytes())); | ||
propertyMapper.from(nettyProperties.getH2cMaxContentLength()) | ||
.whenNonNull() | ||
.to((h2cMaxContentLength) -> httpRequestDecoderSpec | ||
.h2cMaxContentLength((int) h2cMaxContentLength.toBytes())); | ||
propertyMapper.from(nettyProperties.getInitialBufferSize()) | ||
.whenNonNull() | ||
.to((initialBufferSize) -> httpRequestDecoderSpec.initialBufferSize((int) initialBufferSize.toBytes())); | ||
propertyMapper.from(nettyProperties.isValidateHeaders()) | ||
.whenNonNull() | ||
.to(httpRequestDecoderSpec::validateHeaders); | ||
propertyMapper.from(nettyProperties.isValidateHeaders()).to(httpRequestDecoderSpec::validateHeaders); | ||
return httpRequestDecoderSpec; | ||
})); | ||
} | ||
|
@@ -110,7 +106,6 @@ private void customizeRequestDecoder(NettyReactiveWebServerFactory factory, Prop | |
private void maxChunkSize(PropertyMapper propertyMapper, HttpRequestDecoderSpec httpRequestDecoderSpec, | ||
ServerProperties.Netty nettyProperties) { | ||
propertyMapper.from(nettyProperties.getMaxChunkSize()) | ||
.whenNonNull() | ||
.to((maxChunkSize) -> httpRequestDecoderSpec.maxChunkSize((int) maxChunkSize.toBytes())); | ||
} | ||
|
||
|
@@ -122,4 +117,9 @@ private void customizeMaxKeepAliveRequests(NettyReactiveWebServerFactory factory | |
factory.addServerCustomizers((httpServer) -> httpServer.maxKeepAliveRequests(maxKeepAliveRequests)); | ||
} | ||
|
||
private void customizeHttp2MaxHeaderSize(NettyReactiveWebServerFactory factory, long maxHttpRequestHeaderSize) { | ||
factory.addServerCustomizers(((httpServer) -> httpServer.http2Settings( | ||
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. This looks odd to me. This is the first HTTP2-specific setting that I can see. And it being applied regardless of http2 being enabled doesn't look right. I wonder why using HTTP2 requires to set this setting twice as we're already taking care of that in configuring 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. http1.1 uses different netty codec. Compare this stacktrace with the one above and their settings are separate
here is where in reactor-netty-http sets the http2 settings into netty |
||
(http2SettingsSpecBuilder) -> http2SettingsSpecBuilder.maxHeaderListSize(maxHttpRequestHeaderSize)))); | ||
} | ||
|
||
} |
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.
Removed these as well in this method because PropertyMapper is already initialised with
.alwaysApplyingWhenNonNull()
so these are redundantThere 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.
Thanks but please revert those as they are unrelated.