Browse Source

Merge branch '5.3.x'

pull/28742/head
rstoyanchev 4 years ago
parent
commit
a575590c01
  1. 4
      spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java
  2. 23
      spring-webflux/src/main/java/org/springframework/web/reactive/BindingContext.java
  3. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/JettyWebSocketClient.java
  4. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java
  5. 6
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/UndertowWebSocketClient.java
  6. 7
      spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

4
spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java

@ -84,8 +84,8 @@ public class WebExchangeDataBinder extends WebDataBinder { @@ -84,8 +84,8 @@ public class WebExchangeDataBinder extends WebDataBinder {
}
/**
* Protected method to obtain the values for data binding. By default this
* method delegates to {@link #extractValuesToBind(ServerWebExchange)}.
* Obtain the values for data binding. By default, this delegates to
* {@link #extractValuesToBind(ServerWebExchange)}.
* @param exchange the current exchange
* @return a map of bind values
* @since 5.3

23
spring-webflux/src/main/java/org/springframework/web/reactive/BindingContext.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,14 +18,11 @@ package org.springframework.web.reactive; @@ -18,14 +18,11 @@ package org.springframework.web.reactive;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import reactor.core.publisher.Mono;
import org.springframework.http.codec.multipart.Part;
import org.springframework.lang.Nullable;
import org.springframework.ui.Model;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.support.BindingAwareConcurrentModel;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.bind.support.WebExchangeDataBinder;
@ -127,21 +124,9 @@ public class BindingContext { @@ -127,21 +124,9 @@ public class BindingContext {
@Override
public Mono<Map<String, Object>> getValuesToBind(ServerWebExchange exchange) {
Map<String, String> vars = exchange.getAttributeOrDefault(
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap());
MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
Mono<MultiValueMap<String, String>> formData = exchange.getFormData();
Mono<MultiValueMap<String, Part>> multipartData = exchange.getMultipartData();
return Mono.zip(Mono.just(vars), Mono.just(queryParams), formData, multipartData)
.map(tuple -> {
Map<String, Object> result = new TreeMap<>();
tuple.getT1().forEach(result::put);
tuple.getT2().forEach((key, values) -> addBindValue(result, key, values));
tuple.getT3().forEach((key, values) -> addBindValue(result, key, values));
tuple.getT4().forEach((key, values) -> addBindValue(result, key, values));
return result;
});
return super.getValuesToBind(exchange).doOnNext(map ->
map.putAll(exchange.<Map<String, String>>getAttributeOrDefault(
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap())));
}
}

4
spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/JettyWebSocketClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -164,7 +164,7 @@ public class JettyWebSocketClient implements WebSocketClient, Lifecycle { @@ -164,7 +164,7 @@ public class JettyWebSocketClient implements WebSocketClient, Lifecycle {
private HandshakeInfo createHandshakeInfo(URI url, Session jettySession) {
HttpHeaders headers = new HttpHeaders();
jettySession.getUpgradeResponse().getHeaders().forEach(headers::put);
headers.putAll(jettySession.getUpgradeResponse().getHeaders());
String protocol = headers.getFirst("Sec-WebSocket-Protocol");
return new HandshakeInfo(url, headers, Mono.empty(), protocol);
}

4
spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/StandardWebSocketClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -170,7 +170,7 @@ public class StandardWebSocketClient implements WebSocketClient { @@ -170,7 +170,7 @@ public class StandardWebSocketClient implements WebSocketClient {
@Override
public void afterResponse(HandshakeResponse response) {
response.getHeaders().forEach(this.responseHeaders::put);
this.responseHeaders.putAll(response.getHeaders());
}
}

6
spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/UndertowWebSocketClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -243,7 +243,7 @@ public class UndertowWebSocketClient implements WebSocketClient { @@ -243,7 +243,7 @@ public class UndertowWebSocketClient implements WebSocketClient {
@Override
public void beforeRequest(Map<String, List<String>> headers) {
this.requestHeaders.forEach(headers::put);
headers.putAll(this.requestHeaders);
if (this.delegate != null) {
this.delegate.beforeRequest(headers);
}
@ -251,7 +251,7 @@ public class UndertowWebSocketClient implements WebSocketClient { @@ -251,7 +251,7 @@ public class UndertowWebSocketClient implements WebSocketClient {
@Override
public void afterRequest(Map<String, List<String>> headers) {
headers.forEach(this.responseHeaders::put);
this.responseHeaders.putAll(headers);
if (this.delegate != null) {
this.delegate.afterRequest(headers);
}

7
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

@ -975,7 +975,8 @@ public class DispatcherServlet extends FrameworkServlet { @@ -975,7 +975,8 @@ public class DispatcherServlet extends FrameworkServlet {
private void logRequest(HttpServletRequest request) {
LogFormatUtils.traceDebug(logger, traceOn -> {
String params;
if (StringUtils.startsWithIgnoreCase(request.getContentType(), "multipart/")) {
String contentType = request.getContentType();
if (StringUtils.startsWithIgnoreCase(contentType, "multipart/")) {
params = "multipart";
}
else if (isEnableLoggingRequestDetails()) {
@ -984,7 +985,9 @@ public class DispatcherServlet extends FrameworkServlet { @@ -984,7 +985,9 @@ public class DispatcherServlet extends FrameworkServlet {
.collect(Collectors.joining(", "));
}
else {
params = (request.getParameterMap().isEmpty() ? "" : "masked");
// Avoid request body parsing for form data
params = (StringUtils.startsWithIgnoreCase(contentType, "application/x-www-form-urlencoded") ||
!request.getParameterMap().isEmpty() ? "masked" : "");
}
String queryString = request.getQueryString();

Loading…
Cancel
Save