title: Getting comma separated ips from Http header
body: <p>I have a Spring boot app running on Tomcat. I have to resolve each ip to its Geolocation : city , province and Country . However,sometimes I receive ip address as a comma separated String instead of a single ip address. For example , <code>1.39.27.224, 8.37.225.221</code> .
  The code to extract ip from a Http request that I am using :</p>
  
  <pre><code>public static String getIp(final HttpServletRequest request) {
      PreConditions.checkNull(request, "request cannot be null");
      String ip = request.getHeader("X-FORWARDED-FOR");
      if (!StringUtils.hasText(ip)) {
          ip = request.getRemoteAddr();
      }
      return ip;
  }
  </code></pre>