Skip to content

Commit ffcb07f

Browse files
jhoellerBenjamin Reed
authored and
Benjamin Reed
committed
Consistent use of getLocalAddr() without DNS lookups in request adapters
Closes spring-projectsgh-28280
1 parent a45c399 commit ffcb07f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -148,7 +148,7 @@ public Principal getPrincipal() {
148148

149149
@Override
150150
public InetSocketAddress getLocalAddress() {
151-
return new InetSocketAddress(this.servletRequest.getLocalName(), this.servletRequest.getLocalPort());
151+
return new InetSocketAddress(this.servletRequest.getLocalAddr(), this.servletRequest.getLocalPort());
152152
}
153153

154154
@Override
@@ -167,7 +167,8 @@ public InputStream getBody() throws IOException {
167167
}
168168

169169
private boolean isFormPost(HttpServletRequest request) {
170-
return (request.getContentType() != null && request.getContentType().contains(FORM_CONTENT_TYPE) &&
170+
String contentType = request.getContentType();
171+
return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) &&
171172
METHOD_POST.equalsIgnoreCase(request.getMethod()));
172173
}
173174

0 commit comments

Comments
 (0)