忽略大小写获得请求header中的信息

@param request 请求对象{@link HttpServletRequest}
@param nameIgnoreCase 忽略大小写头信息的KEY
@return header值
184371
public final static String getHeaderIgnoreCase(HttpServletRequest request, String nameIgnoreCase) {
		Enumeration<String> names = request.getHeaderNames();
		String name = null;
		while (names.hasMoreElements()) {
			name = names.nextElement();
			if (name != null && name.equalsIgnoreCase(nameIgnoreCase)) {
				return request.getHeader(name);
			}
		}

		return null;
	}
473897
public final static String getHeader(HttpServletRequest request, String name, String charset) {
		final String header = request.getHeader(name);
		if (null != header) {
			try {
				return new String(header.getBytes(CharsetUtil.ISO_8859_1), charset);
			} catch (UnsupportedEncodingException e) {
				throw new UtilException(StrUtil.format("Error charset {} for http request header.", charset));
			}
		}
		return null;
	}
129526
public static String getCookieUsername(HttpServletRequest request) {
		String username = CookieUtil.getCookie("username", request);
		try {
			username = URLDecoder.decode(username, "UTF-8");
		}
		catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
		return username;
	}
1103161
protected Headers getHeaders(Request request)
    {
        Headers.Builder headers = new Headers.Builder();
        MultiMap resolvedHeaders = null;
        if(headerFactory != null)
            resolvedHeaders = headerFactory.getHeaders();

        if(hasEntries(resolvedHeaders))
            resolvedHeaders = resolvedHeaders.merge(request.getHeaders());
        else
            resolvedHeaders = request.getHeaders();

        if(authorizationFactory != null)
        {
            MultiMap authEntries = authorizationFactory.getHeaders();
            if(hasEntries(authEntries))
                resolvedHeaders = resolvedHeaders.merge(authEntries);
        }

        if(resolvedHeaders.getFirst("user-agent") == null)
            headers.add("user-agent",userAgent);

        if(resolvedHeaders.getFirst(CLIENT_VERSION_HEADER_NAME) == null)
            headers.add(CLIENT_VERSION_HEADER_NAME,getClientVersion());

        for (Map.Entry<String, List<String>> entry : resolvedHeaders.entries())
        {
            for (String value : entry.getValue())
            {
                headers.add(entry.getKey(), value);
            }
        }
        return headers.build();
    }
823541
protected List<String> resolveEventFromHttpRequest(final HttpServletRequest request) {
        val mfaRequestHeader = casProperties.getAuthn().getMfa().getRequestHeader();
        val headers = request.getHeaders(mfaRequestHeader);
        if (headers != null && headers.hasMoreElements()) {
            LOGGER.debug("Received request header [{}] as [{}]", mfaRequestHeader, headers);
            return Collections.list(headers);
        }

        val mfaRequestParameter = casProperties.getAuthn().getMfa().getRequestParameter();
        val params = request.getParameterValues(mfaRequestParameter);
        if (params != null && params.length > 0) {
            LOGGER.debug("Received request parameter [{}] as [{}]", mfaRequestParameter, params);
            return Arrays.stream(params).collect(Collectors.toList());
        }

        val attributeName = casProperties.getAuthn().getMfa().getSessionAttribute();
        val session = request.getSession(false);
        var attributeValue = session != null ? session.getAttribute(attributeName) : null;
        if (attributeValue == null) {
            LOGGER.trace("No value could be found for session attribute [{}]. Checking request attributes...", attributeName);
            attributeValue = request.getAttribute(attributeName);
        }

        if (attributeValue == null) {
            LOGGER.trace("No value could be found for [{}]", attributeName);
            return null;
        }

        val values = CollectionUtils.toCollection(attributeValue);
        LOGGER.debug("Found values [{}] mapped to attribute name [{}]", values, attributeName);
        return values.stream().map(Object::toString).collect(Collectors.toList());
    }
333942
public Cookie getCookieValueByName(final HttpServletRequest request,
            final String name) {
        if (request.getCookies() == null) {
            return null;
        }
        for (int i = 0; i < request.getCookies().length; i++) {
            if (request.getCookies()[i].getName().equals(name)) {
                return request.getCookies()[i];
            }
        }
        return null;
    }
1104806
public String header(String name) {
    Objects.requireNonNull(name);
    return headers.get(name);
  }
997570
public String header(Header name) {
		if(null == name) {
			return null;
		}
		return header(name.toString());
	}
92635
public static  String getRootDomain(HttpServletRequest request) {
		String host = request.getHeader(WebConstants.HEADER_FORWARDED_HOST);
		if(StringUtils.isBlank(host))host = request.getServerName();
		
		if(IpUtils.isIp(host) || IpUtils.LOCAL_HOST.equals(host)){
			return host;
		}
		
		String[] segs = StringUtils.split(host, POINT);
		int len = segs.length;
		return segs[len - 2] + POINT+ segs[len - 1];
	}
700522
public static Map<String, String> getRequestHeaders(final HttpServletRequest request) {
        val headers = new LinkedHashMap<String, Object>();
        val headerNames = request.getHeaderNames();
        if (headerNames != null) {
            while (headerNames.hasMoreElements()) {
                val headerName = headerNames.nextElement();
                val headerValue = StringUtils.stripToEmpty(request.getHeader(headerName));
                headers.put(headerName, headerValue);
            }
        }
        return (Map) headers;
    }
251107
public static String getRequestEncoding(ServletRequest request) {
		String requestEncoding = request.getCharacterEncoding();
		return requestEncoding != null ? requestEncoding : DEFAULT_REQUEST_ENCODING;
	}
1329923
public String getRequestInfo(HttpServletRequest request) {
        return String.format("URI: %s; Scheme: %s; Host: %s; Port: %s; Origin: %s; Method: %s",
                             request.getRequestURI(),
                             request.getScheme(),
                             request.getServerName(),
                             request.getServerPort(),
                             request.getHeader("Origin"),
                             request.getMethod());
    }
990430
public static String getHeaders(HttpServletRequest request) {
        String headerString = "";
        Enumeration<String> headerNames = request.getHeaderNames();

        while (headerNames.hasMoreElements()) {
            String name = headerNames.nextElement();
            if (name.equals(Constants.ODO_PROXY_HEADER)) {
                // skip.. don't want to log this
                continue;
            }

            if (headerString.length() != 0) {
                headerString += "\n";
            }

            headerString += name + ": " + request.getHeader(name);
        }

        return headerString;
    }
351817
protected CORSRequestType checkRequestType(final HttpServletRequest request) {
        CORSRequestType requestType = CORSRequestType.INVALID_CORS;
        if (request == null) {
            throw new IllegalArgumentException("Request is null");
        }
        String originHeader = request.getHeader(REQUEST_HEADER_ORIGIN);
        // Section 6.1.1 and Section 6.2.1
        if (originHeader != null) {
            if (originHeader.isEmpty()) {
                requestType = CORSRequestType.INVALID_CORS;
            } else if (!isValidOrigin(originHeader)) {
                requestType = CORSRequestType.INVALID_CORS;
            } else if (isLocalOrigin(request, originHeader)) {
                return CORSRequestType.NOT_CORS;
            } else {
                String method = request.getMethod();
                if (method != null) {
                    if ("OPTIONS".equals(method)) {
                        String accessControlRequestMethodHeader =
                                request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
                        if (accessControlRequestMethodHeader != null
                                && !accessControlRequestMethodHeader.isEmpty()) {
                            requestType = CORSRequestType.PRE_FLIGHT;
                        } else if (accessControlRequestMethodHeader != null
                                && accessControlRequestMethodHeader.isEmpty()) {
                            requestType = CORSRequestType.INVALID_CORS;
                        } else {
                            requestType = CORSRequestType.ACTUAL;
                        }
                    } else if ("GET".equals(method) || "HEAD".equals(method)) {
                        requestType = CORSRequestType.SIMPLE;
                    } else if ("POST".equals(method)) {
                        String mediaType = getMediaType(request.getContentType());
                        if (mediaType != null) {
                            if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES.contains(mediaType)) {
                                requestType = CORSRequestType.SIMPLE;
                            } else {
                                requestType = CORSRequestType.ACTUAL;
                            }
                        } else {
                            requestType = CORSRequestType.ACTUAL;
                        }
                    } else {
                        requestType = CORSRequestType.ACTUAL;
                    }
                }
            }
        } else {
            requestType = CORSRequestType.NOT_CORS;
        }

        return requestType;
    }
600023
public String getParameterIgnoreCase(String name) {
        for (Map.Entry<String, String[]> entry : customParameters.entrySet()) {
            if (entry.getKey().equalsIgnoreCase(name)) {
                return StringUtils.join(entry.getValue(), ",");
            }
        }
        return null;
    }
506970
public static Cookie findCookie(HttpServletRequest request, String name) {
        if (request != null) {
            Cookie[] cookies = request.getCookies();
            if (cookies != null && cookies.length > 0) {
                for (Cookie cookie : cookies) {
                    if (cookie.getName().equals(name)) {
                        return cookie;
                    }
                }
            }
        }
        return null;
    }
709292
public RequestTemplate header(String name, Iterable<String> values) {
    if (name == null || name.isEmpty()) {
      throw new IllegalArgumentException("name is required.");
    }
    if (values == null) {
      values = Collections.emptyList();
    }

    return appendHeader(name, values);
  }