MockHttpServletRequest.getRequestURL aligns with getServerName/Port
Issue: SPR-16138
(cherry picked from commit 0edf4d6)
This commit is contained in:
@@ -1103,13 +1103,18 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
StringBuffer url = new StringBuffer(this.scheme).append("://").append(this.serverName);
|
||||
if (this.serverPort > 0 && ((HTTP.equalsIgnoreCase(this.scheme) && this.serverPort != 80) ||
|
||||
(HTTPS.equalsIgnoreCase(this.scheme) && this.serverPort != 443))) {
|
||||
url.append(':').append(this.serverPort);
|
||||
String scheme = getScheme();
|
||||
String server = getServerName();
|
||||
int port = getServerPort();
|
||||
String uri = getRequestURI();
|
||||
|
||||
StringBuffer url = new StringBuffer(scheme).append("://").append(server);
|
||||
if (port > 0 && ((HTTP.equalsIgnoreCase(scheme) && port != 80) ||
|
||||
(HTTPS.equalsIgnoreCase(scheme) && port != 443))) {
|
||||
url.append(':').append(port);
|
||||
}
|
||||
if (StringUtils.hasText(getRequestURI())) {
|
||||
url.append(getRequestURI());
|
||||
if (StringUtils.hasText(uri)) {
|
||||
url.append(uri);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
@@ -1219,12 +1224,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Part getPart(String name) throws IOException, IllegalStateException, ServletException {
|
||||
public Part getPart(String name) throws IOException, ServletException {
|
||||
return this.parts.getFirst(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Part> getParts() throws IOException, IllegalStateException, ServletException {
|
||||
public Collection<Part> getParts() throws IOException, ServletException {
|
||||
List<Part> result = new LinkedList<Part>();
|
||||
for (List<Part> list : this.parts.values()) {
|
||||
result.addAll(list);
|
||||
|
||||
Reference in New Issue
Block a user