fix double slashes in eureka server
fixes gh-100
This commit is contained in:
@@ -69,10 +69,14 @@ public class EurekaController {
|
||||
return map;
|
||||
}
|
||||
|
||||
private void populateBase(HttpServletRequest request, Map<String, Object> model) {
|
||||
protected void populateBase(HttpServletRequest request, Map<String, Object> model) {
|
||||
String servletPath = request.getServletPath();
|
||||
String path = request.getContextPath() + (servletPath==null ? "" : servletPath);
|
||||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
|
||||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
|
||||
|
||||
if (!basePath.endsWith("/")) {
|
||||
basePath += "/";
|
||||
}
|
||||
|
||||
model.put("time", new Date());
|
||||
model.put("basePath", basePath);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springframework.cloud.netflix.eureka.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.springframework.cloud.netflix.eureka.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -54,4 +56,17 @@ public class ApplicationTests {
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noDoubleSlashes() {
|
||||
String basePath = "http://localhost:" + port + "/";
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
basePath, String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
String body = entity.getBody();
|
||||
assertNotNull(body);
|
||||
assertFalse("basePath contains double slashes", body.contains(basePath+"/"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user