From ffcb07f7a9d198b54651c6f3903f574a2e4743fc Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 8 Apr 2022 13:57:09 +0200 Subject: [PATCH] Consistent use of getLocalAddr() without DNS lookups in request adapters Closes gh-28280 --- .../http/server/ServletServerHttpRequest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java index 489dfa294f55..2e77f598058c 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,7 +148,7 @@ public Principal getPrincipal() { @Override public InetSocketAddress getLocalAddress() { - return new InetSocketAddress(this.servletRequest.getLocalName(), this.servletRequest.getLocalPort()); + return new InetSocketAddress(this.servletRequest.getLocalAddr(), this.servletRequest.getLocalPort()); } @Override @@ -167,7 +167,8 @@ public InputStream getBody() throws IOException { } private boolean isFormPost(HttpServletRequest request) { - return (request.getContentType() != null && request.getContentType().contains(FORM_CONTENT_TYPE) && + String contentType = request.getContentType(); + return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) && METHOD_POST.equalsIgnoreCase(request.getMethod())); }