Updates to version 5.0.0-SNAPSHOT
Changes for Framework 7
This commit is contained in:
@@ -81,7 +81,7 @@ public class FunctionController {
|
||||
.getRequest()).getMultiFileMap();
|
||||
if (!CollectionUtils.isEmpty(multiFileMap)) {
|
||||
List<Message<MultipartFile>> files = multiFileMap.values().stream().flatMap(v -> v.stream())
|
||||
.map(file -> MessageBuilder.withPayload(file).copyHeaders(wrapper.getHeaders()).build())
|
||||
.map(file -> MessageBuilder.withPayload(file).copyHeaders(wrapper.getHeaders().asMultiValueMap()).build())
|
||||
.collect(Collectors.toList());
|
||||
FunctionInvocationWrapper function = wrapper.getFunction();
|
||||
|
||||
@@ -199,7 +199,7 @@ public class FunctionController {
|
||||
wrapper.getHeaders().addAll(key, Arrays.asList(request.getHeaderValues(key)));
|
||||
}
|
||||
|
||||
HttpHeaders headers = HttpHeaders.writableHttpHeaders(wrapper.getHeaders());
|
||||
HttpHeaders headers = HttpHeaders.copyOf(wrapper.getHeaders());
|
||||
headers.set("uri", ((ServletWebRequest) request).getRequest().getRequestURI());
|
||||
|
||||
String argument = (String) request.getAttribute(WebRequestConstants.ARGUMENT,
|
||||
|
||||
@@ -65,8 +65,8 @@ public class HttpSupplier implements Supplier<Flux<?>> {
|
||||
}
|
||||
|
||||
private Flux<?> get(WebClient client) {
|
||||
Flux<?> result = client.get().uri(this.props.getSource().getUrl()).exchange()
|
||||
.flatMap(this::transform).repeat();
|
||||
Flux<?> result = client.get().uri(this.props.getSource().getUrl()).exchangeToMono(this::transform)
|
||||
.repeat();
|
||||
if (this.props.isDebug()) {
|
||||
result = result.log();
|
||||
}
|
||||
|
||||
@@ -192,11 +192,11 @@ public class SupplierExporter implements SmartLifecycle {
|
||||
}
|
||||
Mono<ClientResponse> result = this.client.post().uri(uri)
|
||||
.headers(headers -> headers(headers, destination, value)).bodyValue(body)
|
||||
.exchange()
|
||||
.doOnNext(response -> {
|
||||
.exchangeToMono(response -> {
|
||||
if (this.debug) {
|
||||
logger.debug("Response STATUS: " + response.statusCode());
|
||||
}
|
||||
return Mono.just(response);
|
||||
});
|
||||
if (this.debug) {
|
||||
result = result.log();
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class HeaderUtils {
|
||||
for (String name : headers.keySet()) {
|
||||
Object value = headers.get(name);
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
if (!IGNORED.containsKey(name) && !ignoredHeders.contains(name)) {
|
||||
if (!IGNORED.containsHeader(name) && !ignoredHeders.contains(name)) {
|
||||
Collection<?> values = multi(value);
|
||||
for (Object object : values) {
|
||||
result.set(name, object.toString());
|
||||
@@ -80,10 +80,10 @@ public final class HeaderUtils {
|
||||
|
||||
public static HttpHeaders sanitize(HttpHeaders request, List<String> ignoredHeders, List<String> requestOnlyHeaders) {
|
||||
HttpHeaders result = new HttpHeaders();
|
||||
for (String name : request.keySet()) {
|
||||
for (String name : request.headerNames()) {
|
||||
List<String> value = request.get(name);
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
if (!IGNORED.containsKey(name) && !REQUEST_ONLY.containsKey(name) && !ignoredHeders.contains(name) && !requestOnlyHeaders.contains(name)) {
|
||||
if (!IGNORED.containsHeader(name) && !REQUEST_ONLY.containsHeader(name) && !ignoredHeders.contains(name) && !requestOnlyHeaders.contains(name)) {
|
||||
result.put(name, value);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public final class HeaderUtils {
|
||||
|
||||
public static MessageHeaders fromHttp(HttpHeaders headers) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
for (String name : headers.keySet()) {
|
||||
for (String name : headers.headerNames()) {
|
||||
Collection<?> values = multi(headers.get(name));
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
Object value = values == null ? null
|
||||
|
||||
@@ -60,7 +60,7 @@ public class HeadersToMessageTests {
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body("{\"name\":\"Bob\",\"age\":25}"), String.class);
|
||||
assertThat(postForEntity.getBody()).isEqualTo("{\"name\":\"Bob\",\"age\":25}");
|
||||
assertThat(postForEntity.getHeaders().containsKey("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().containsHeader("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().get("x-content-type").get(0))
|
||||
.isEqualTo("application/xml");
|
||||
assertThat(postForEntity.getHeaders().get("foo").get(0)).isEqualTo("bar");
|
||||
@@ -69,7 +69,7 @@ public class HeadersToMessageTests {
|
||||
postForEntity = this.rest.postForEntity(new URI("/functions/string"),
|
||||
"{\"name\":\"Bob\",\"age\":25}", String.class);
|
||||
assertThat(postForEntity.getBody()).isEqualTo("{\"name\":\"Bob\",\"age\":25}");
|
||||
assertThat(postForEntity.getHeaders().containsKey("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().containsHeader("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().get("x-content-type").get(0))
|
||||
.isEqualTo("application/xml");
|
||||
assertThat(postForEntity.getHeaders().get("foo").get(0)).isEqualTo("bar");
|
||||
|
||||
@@ -170,7 +170,7 @@ public class HttpPostIntegrationTests {
|
||||
.post(new URI("/messages")).contentType(MediaType.APPLICATION_JSON)
|
||||
.header("x-foo", "bar").body("[\"foo\",\"bar\"]"), String.class);
|
||||
assertThat(result.getHeaders().getFirst("x-foo")).isEqualTo("bar");
|
||||
assertThat(result.getHeaders()).doesNotContainKey("id");
|
||||
assertThat(result.getHeaders().headerNames()).doesNotContain("id");
|
||||
assertThat(result.getBody()).isEqualTo("[\"(FOO)\",\"(BAR)\"]");
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FunctionEndpointInitializerTests {
|
||||
headers.set("Accept", "application/json");
|
||||
HttpEntity entity = new HttpEntity(headers);
|
||||
|
||||
String urlTemplate = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + "/nullPayload")
|
||||
String urlTemplate = UriComponentsBuilder.fromUriString("http://localhost:" + port + "/nullPayload")
|
||||
.queryParam("fname", "Jim").queryParam("lname", "Lahey").encode().toUriString();
|
||||
|
||||
ResponseEntity<String> response = testRestTemplate.exchange(urlTemplate, HttpMethod.GET, entity, String.class);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class HeadersToMessageTests {
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body("{\"name\":\"Bob\",\"age\":25}"), String.class);
|
||||
assertThat(postForEntity.getBody()).isEqualTo("{\"name\":\"Bob\",\"age\":25}");
|
||||
assertThat(postForEntity.getHeaders().containsKey("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().headerNames()).contains("x-content-type");
|
||||
assertThat(postForEntity.getHeaders().get("x-content-type").get(0))
|
||||
.isEqualTo("application/xml");
|
||||
assertThat(postForEntity.getHeaders().get("foo").get(0)).isEqualTo("bar");
|
||||
@@ -75,7 +75,7 @@ public class HeadersToMessageTests {
|
||||
.body("{\"name\":\"Bob\",\"age\":25}"), String.class);
|
||||
assertThat(postForEntity.getBody())
|
||||
.isEqualTo("{\"name\":\"Bob\",\"age\":25,\"foo\":\"bar\"}");
|
||||
assertThat(postForEntity.getHeaders().containsKey("x-context-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().headerNames()).contains("x-context-type");
|
||||
assertThat(postForEntity.getHeaders().get("x-context-type").get(0))
|
||||
.isEqualTo("rubbish");
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class HttpPostIntegrationTests {
|
||||
.accept(MediaType.valueOf("application/stream+json"))
|
||||
.header("x-foo", "bar").body("[\"foo\",\"bar\"]"), String.class);
|
||||
assertThat(result.getHeaders().getFirst("x-foo")).isEqualTo("bar");
|
||||
assertThat(result.getHeaders()).doesNotContainKey("id");
|
||||
assertThat(result.getHeaders().headerNames()).doesNotContain("id");
|
||||
assertThat(result.getBody()).isEqualTo("[\"(FOO)\",\"(BAR)\"]");
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class HttpPostIntegrationTests {
|
||||
.accept(MediaType.valueOf("application/stream+json"))
|
||||
.body("[\"foo\",\"bar\"]"), String.class);
|
||||
assertThat(result.getHeaders().getFirst("foo")).isEqualTo("bar");
|
||||
assertThat(result.getHeaders()).doesNotContainKey("id");
|
||||
assertThat(result.getHeaders().headerNames()).doesNotContain("id");
|
||||
assertThat(result.getBody()).isEqualTo("[\"(FOO)\",\"(BAR)\"]");
|
||||
}
|
||||
|
||||
|
||||
@@ -72,19 +72,18 @@ public class RoutingFunctionTests {
|
||||
public void testFunctionMessage() throws Exception {
|
||||
|
||||
HttpEntity<String> postForEntity = this.rest
|
||||
.exchange(RequestEntity.post(new URI("/functions/" + RoutingFunction.FUNCTION_NAME))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("spring.cloud.function.definition", "employee")
|
||||
.header("abc", "abc")
|
||||
.header("xyz", "xyz")
|
||||
.body("{\"name\":\"Bob\",\"age\":25}"), String.class);
|
||||
.exchange(RequestEntity.post(new URI("/functions/" + RoutingFunction.FUNCTION_NAME))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("spring.cloud.function.definition", "employee")
|
||||
.header("abc", "abc")
|
||||
.header("xyz", "xyz")
|
||||
.body("{\"name\":\"Bob\",\"age\":25}"), String.class);
|
||||
assertThat(postForEntity.getBody()).isEqualTo("{\"name\":\"Bob\",\"age\":25}");
|
||||
assertThat(postForEntity.getHeaders().containsKey("x-content-type")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().headerNames()).contains("x-content-type");
|
||||
assertThat(postForEntity.getHeaders().get("x-content-type").get(0))
|
||||
.isEqualTo("application/xml");
|
||||
assertThat(postForEntity.getHeaders().containsKey("spring.cloud.function.definition")).isTrue();
|
||||
assertThat(postForEntity.getHeaders().containsKey("abc")).isFalse();
|
||||
assertThat(postForEntity.getHeaders().containsKey("xyz")).isFalse();
|
||||
.isEqualTo("application/xml");
|
||||
assertThat(postForEntity.getHeaders().headerNames()).contains("spring.cloud.function.definition")
|
||||
.doesNotContain("abc", "xyz");
|
||||
assertThat(postForEntity.getHeaders().get("foo").get(0)).isEqualTo("bar");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user