Merge branch '5.3.x' into main
This commit is contained in:
commit
4782d4c080
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,7 +28,6 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.http.server.PathContainer;
|
|
||||||
import org.springframework.http.server.RequestPath;
|
import org.springframework.http.server.RequestPath;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
@ -214,8 +213,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||||
handler = obtainApplicationContext().getBean(handlerName);
|
handler = obtainApplicationContext().getBean(handlerName);
|
||||||
}
|
}
|
||||||
validateHandler(handler, request);
|
validateHandler(handler, request);
|
||||||
PathContainer pathWithinMapping = pattern.extractPathWithinPattern(path.pathWithinApplication());
|
String pathWithinMapping = pattern.extractPathWithinPattern(path.pathWithinApplication()).value();
|
||||||
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping.value(), null);
|
pathWithinMapping = UrlPathHelper.defaultInstance.removeSemicolonContent(pathWithinMapping);
|
||||||
|
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -102,7 +102,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||||
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("/welcome.html");
|
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("/welcome.html");
|
||||||
assertThat(request.getAttribute(BEST_MATCHING_HANDLER_ATTRIBUTE)).isEqualTo(bean);
|
assertThat(request.getAttribute(BEST_MATCHING_HANDLER_ATTRIBUTE)).isEqualTo(bean);
|
||||||
|
|
||||||
request = PathPatternsTestUtils.initRequest("GET", "/welcome.x", usePathPatterns);
|
request = PathPatternsTestUtils.initRequest("GET", "/welcome.x;jsessionid=123", usePathPatterns);
|
||||||
chain = getHandler(hm, request);
|
chain = getHandler(hm, request);
|
||||||
assertThat(chain.getHandler()).isSameAs(otherBean);
|
assertThat(chain.getHandler()).isSameAs(otherBean);
|
||||||
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("welcome.x");
|
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("welcome.x");
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -79,13 +79,7 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Connection already closed (but not removed yet) for " + sockJsSession);
|
logger.debug("Connection already closed (but not removed yet) for " + sockJsSession);
|
||||||
}
|
}
|
||||||
SockJsFrame frame = SockJsFrame.closeFrameGoAway();
|
writeFrame(SockJsFrame.closeFrameGoAway(), request, response, sockJsSession);
|
||||||
try {
|
|
||||||
response.getBody().write(frame.getContentBytes());
|
|
||||||
}
|
|
||||||
catch (IOException ex) {
|
|
||||||
throw new SockJsException("Failed to send " + frame, sockJsSession.getId(), ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!sockJsSession.isActive()) {
|
else if (!sockJsSession.isActive()) {
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
|
|
@ -97,7 +91,14 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Another " + getTransportType() + " connection still open for " + sockJsSession);
|
logger.debug("Another " + getTransportType() + " connection still open for " + sockJsSession);
|
||||||
}
|
}
|
||||||
String formattedFrame = getFrameFormat(request).format(SockJsFrame.closeFrameAnotherConnectionOpen());
|
writeFrame(SockJsFrame.closeFrameAnotherConnectionOpen(), request, response, sockJsSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeFrame(SockJsFrame frame, ServerHttpRequest request, ServerHttpResponse response,
|
||||||
|
AbstractHttpSockJsSession sockJsSession) {
|
||||||
|
|
||||||
|
String formattedFrame = getFrameFormat(request).format(frame);
|
||||||
try {
|
try {
|
||||||
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
|
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +106,6 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
|
||||||
throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex);
|
throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected abstract MediaType getContentType();
|
protected abstract MediaType getContentType();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -257,7 +257,8 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
|
||||||
synchronized (this.responseLock) {
|
synchronized (this.responseLock) {
|
||||||
try {
|
try {
|
||||||
if (isClosed()) {
|
if (isClosed()) {
|
||||||
response.getBody().write(SockJsFrame.closeFrameGoAway().getContentBytes());
|
String formattedFrame = frameFormat.format(SockJsFrame.closeFrameGoAway());
|
||||||
|
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.response = response;
|
this.response = response;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue