Skip to content

Commit

Permalink
Adds max response header configuration.
Browse files Browse the repository at this point in the history
fixes gh-1457
  • Loading branch information
spencergibb committed Jan 14, 2020
1 parent 427983e commit 64a579d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,14 @@ else if (pool.getType() == FIXED) {
}

HttpClient httpClient = HttpClient.create(connectionProvider)
.tcpConfiguration(tcpClient -> {
.httpResponseDecoder(spec -> {
if (properties.getMaxHeaderSize() != null) {
// cast to int is ok, since @Max is Integer.MAX_VALUE
spec.maxHeaderSize(
(int) properties.getMaxHeaderSize().toBytes());
}
return spec;
}).tcpConfiguration(tcpClient -> {

if (properties.getConnectTimeout() != null) {
tcpClient = tcpClient.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Collection;
import java.util.List;

import javax.validation.constraints.Max;

import reactor.netty.resources.ConnectionProvider;
import reactor.netty.tcp.SslProvider;

Expand All @@ -35,6 +37,7 @@
import org.springframework.boot.web.server.WebServerException;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.ResourceUtils;
import org.springframework.util.unit.DataSize;

/**
* Configuration properties for the Netty {@link reactor.netty.http.client.HttpClient}.
Expand All @@ -48,6 +51,9 @@ public class HttpClientProperties {
/** The response timeout. */
private Duration responseTimeout;

/** The max response header size. */
private DataSize maxHeaderSize;

/** Pool configuration for Netty HttpClient. */
private Pool pool = new Pool();

Expand Down Expand Up @@ -76,6 +82,15 @@ public void setResponseTimeout(Duration responseTimeout) {
this.responseTimeout = responseTimeout;
}

@Max(Integer.MAX_VALUE)
public DataSize getMaxHeaderSize() {
return maxHeaderSize;
}

public void setMaxHeaderSize(DataSize maxHeaderSize) {
this.maxHeaderSize = maxHeaderSize;
}

public Pool getPool() {
return pool;
}
Expand Down Expand Up @@ -114,6 +129,7 @@ public String toString() {
return new ToStringCreator(this)
.append("connectTimeout", connectTimeout)
.append("responseTimeout", responseTimeout)
.append("maxHeaderSize", maxHeaderSize)
.append("pool", pool)
.append("proxy", proxy)
.append("ssl", ssl)
Expand Down

0 comments on commit 64a579d

Please sign in to comment.