code: public static Map<String, Object> createHeadersMap(HttpServletRequest request) {
          Map<String, Object> headersMap = new HashMap<>();
          for (Enumeration headerNameEnum = request.getHeaderNames(); headerNameEnum.hasMoreElements(); ) {
              String headerName = (String)headerNameEnum.nextElement();
              List<String> headerValues = new ArrayList<String>();
  
              CollectionUtils.addAll(headerValues, request.getHeaders(headerName));
  
              if (headerValues.size() == 1) {
                  headersMap.put(headerName, headerValues.get(0));
              } else {
                  headersMap.put(headerName, headerValues.toArray(new String[headerValues.size()]));
              }
          }
  
          return headersMap;
      }
docs: Creates a map from the headers in the specified request. Multi value headers will be in an array.
  
  @param request the request