Browse Source

Merge branch '2.2.x'

pull/1601/head
Spencer Gibb 5 years ago
parent
commit
ad228e611c
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 1
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java
  2. 14
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java
  3. 22
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java
  4. 4
      spring-cloud-gateway-mvc/src/test/java/org/springframework/cloud/gateway/mvc/ProductionConfigurationTests.java
  5. 4
      spring-cloud-gateway-webflux/src/test/java/org/springframework/cloud/gateway/webflux/ProductionConfigurationTests.java

1
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java

@ -730,6 +730,7 @@ public class GatewayAutoConfiguration { @@ -730,6 +730,7 @@ public class GatewayAutoConfiguration {
webSocketClient.setMaxFramePayloadLength(
properties.getWebsocket().getMaxFramePayloadLength());
}
webSocketClient.setHandlePing(properties.getWebsocket().isProxyPing());
return webSocketClient;
}

14
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java

@ -603,6 +603,9 @@ public class HttpClientProperties { @@ -603,6 +603,9 @@ public class HttpClientProperties {
/** Max frame payload length. */
private Integer maxFramePayloadLength;
/** Proxy ping frames to downstream services, defaults to true. */
private boolean proxyPing = true;
public Integer getMaxFramePayloadLength() {
return this.maxFramePayloadLength;
}
@ -611,10 +614,19 @@ public class HttpClientProperties { @@ -611,10 +614,19 @@ public class HttpClientProperties {
this.maxFramePayloadLength = maxFramePayloadLength;
}
public boolean isProxyPing() {
return proxyPing;
}
public void setProxyPing(boolean proxyPing) {
this.proxyPing = proxyPing;
}
@Override
public String toString() {
return new ToStringCreator(this)
.append("maxFramePayloadLength", maxFramePayloadLength).toString();
.append("maxFramePayloadLength", maxFramePayloadLength)
.append("proxyPing", proxyPing).toString();
}
}

22
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/HttpBinCompatibleController.java

@ -63,16 +63,17 @@ public class HttpBinCompatibleController { @@ -63,16 +63,17 @@ public class HttpBinCompatibleController {
return "httpbin compatible home";
}
@RequestMapping(path = "/headers", method = { RequestMethod.GET,
RequestMethod.POST }, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/headers", method = { RequestMethod.GET, RequestMethod.POST },
produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> headers(ServerWebExchange exchange) {
Map<String, Object> result = new HashMap<>();
result.put("headers", getHeaders(exchange));
return result;
}
@RequestMapping(path = "/multivalueheaders", method = { RequestMethod.GET,
RequestMethod.POST }, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/multivalueheaders",
method = { RequestMethod.GET, RequestMethod.POST },
produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> multiValueHeaders(ServerWebExchange exchange) {
Map<String, Object> result = new HashMap<>();
result.put("headers", exchange.getRequest().getHeaders());
@ -86,7 +87,8 @@ public class HttpBinCompatibleController { @@ -86,7 +87,8 @@ public class HttpBinCompatibleController {
return Mono.just(get(exchange)).delayElement(Duration.ofSeconds(delay));
}
@RequestMapping(path = "/anything/{anything}", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/anything/{anything}",
produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> anything(ServerWebExchange exchange,
@PathVariable(required = false) String anything) {
return get(exchange);
@ -107,7 +109,8 @@ public class HttpBinCompatibleController { @@ -107,7 +109,8 @@ public class HttpBinCompatibleController {
return result;
}
@RequestMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> postFormData(
@RequestBody Mono<MultiValueMap<String, Part>> parts) {
// StringDecoder decoder = StringDecoder.allMimeTypes(true);
@ -123,13 +126,16 @@ public class HttpBinCompatibleController { @@ -123,13 +126,16 @@ public class HttpBinCompatibleController {
}).map(files -> Collections.singletonMap("files", files));
}
@RequestMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/post",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> postUrlEncoded(ServerWebExchange exchange)
throws IOException {
return post(exchange, null);
}
@RequestMapping(path = "/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/post", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
public Mono<Map<String, Object>> post(ServerWebExchange exchange,
@RequestBody(required = false) String body) throws IOException {
HashMap<String, Object> ret = new HashMap<>();

4
spring-cloud-gateway-mvc/src/test/java/org/springframework/cloud/gateway/mvc/ProductionConfigurationTests.java

@ -55,8 +55,8 @@ import org.springframework.web.util.UriComponentsBuilder; @@ -55,8 +55,8 @@ import org.springframework.web.util.UriComponentsBuilder;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(properties = {
"spring.cloud.gateway.proxy.auto-forward=baz" }, webEnvironment = WebEnvironment.RANDOM_PORT)
@SpringBootTest(properties = { "spring.cloud.gateway.proxy.auto-forward=baz" },
webEnvironment = WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = TestApplication.class)
public class ProductionConfigurationTests {

4
spring-cloud-gateway-webflux/src/test/java/org/springframework/cloud/gateway/webflux/ProductionConfigurationTests.java

@ -58,8 +58,8 @@ import org.springframework.web.util.UriComponentsBuilder; @@ -58,8 +58,8 @@ import org.springframework.web.util.UriComponentsBuilder;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(properties = {
"spring.cloud.gateway.proxy.auto-forward=baz" }, webEnvironment = WebEnvironment.RANDOM_PORT)
@SpringBootTest(properties = { "spring.cloud.gateway.proxy.auto-forward=baz" },
webEnvironment = WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = TestApplication.class)
@DirtiesContext
public class ProductionConfigurationTests {

Loading…
Cancel
Save