提交 e60e8dc5 编写于 作者: R Rossen Stoyanchev

Fix issue with getting SockJS path

Issue: SPR-10923
上级 6ddacdc0
......@@ -374,7 +374,7 @@ public abstract class AbstractSockJsService implements SockJsService {
// Try SockJS prefix hints
if (!this.validSockJsPrefixes.isEmpty()) {
for (String prefix : this.validSockJsPrefixes) {
int index = path.indexOf(prefix);
int index = path.lastIndexOf(prefix);
if (index != -1) {
this.knownSockJsPrefixes.add(path.substring(0, index + prefix.length()));
return path.substring(index + prefix.length());
......
......@@ -113,6 +113,17 @@ public class AbstractSockJsServiceTests extends AbstractHttpRequestTests {
assertSame(this.handler, this.service.handler);
}
// SPR-10923
@Test
public void getSockJsPathWithPartlyMatchingServletPath() throws Exception {
this.service.setValidSockJsPrefixes("/snake");
handleRequest("GET", "/snakedemo/snake/info", HttpStatus.OK);
assertTrue(this.servletResponse.getContentAsString().startsWith("{\"entropy\":"));
}
@Test
public void validateRequest() throws Exception {
......@@ -146,7 +157,7 @@ public class AbstractSockJsServiceTests extends AbstractHttpRequestTests {
String body = this.servletResponse.getContentAsString();
assertEquals("{\"entropy\"", body.substring(0, body.indexOf(':')));
assertEquals(",\"origins\":[\"*:*\"],\"cookie_needed\":false,\"websocket\":true}",
assertEquals(",\"origins\":[\"*:*\"],\"cookie_needed\":true,\"websocket\":true}",
body.substring(body.indexOf(',')));
this.service.setSessionCookieNeeded(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册