List of usage examples for org.springframework.http HttpHeaders keySet
@Override
public Set<String> keySet()
From source file:org.lightadmin.core.web.util.ResponseUtils.java
public static void addImageResourceHeaders(HttpServletResponse response, HttpHeaders httpHeaders) { for (String httpHeaderKey : httpHeaders.keySet()) { response.setHeader(httpHeaderKey, httpHeaders.get(httpHeaderKey).get(0)); }/*from w w w . jav a 2s. c om*/ }
From source file:de.zib.gndms.gndmc.utils.DefaultResponseExtractor.java
public static String getLocation(final HttpHeaders headers) { for (String header : headers.keySet()) { if ("Location".equals(header)) { try { return URLDecoder.decode(headers.get(header).get(0), "utf8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("The system does not support utf8 decoding!"); }/*from w ww .j a v a2 s. c o m*/ } } return null; }
From source file:de.zib.gndms.gndmc.utils.DefaultResponseExtractor.java
public static List<String> getCookies(final HttpHeaders headers) { final List<String> cookies = new LinkedList<String>(); for (String header : headers.keySet()) { if ("Set-Cookie".equals(header)) { for (String value : headers.get(header)) { cookies.add(value);/* w ww . ja va2s.c o m*/ } } } return cookies; }
From source file:io.pivotalservices.wiretaprouteservice.CatchAllController.java
private static void printHeaders(String type, HttpHeaders headers) { StringBuilder sb = new StringBuilder(type + " HEADER "); sb.append(System.lineSeparator()); for (String key : headers.keySet()) { List<String> values = headers.getValuesAsList(key); sb.append("KEY: " + key + " VALUES: "); for (String value : values) { sb.append(value + "; "); }/*from ww w. ja v a 2 s . c om*/ sb.append(System.lineSeparator()); } logger.debug(sb.toString()); }
From source file:io.neba.core.mvc.MultipartSlingHttpServletRequestTest.java
@SuppressWarnings("rawtypes") private void mockHeaders(final HttpHeaders headers) { Enumeration headerNames = fromIterator(headers.keySet().iterator()); when(this.wrappedRequest.getHeaderNames()).thenReturn(headerNames); for (Entry<String, List<String>> entry : headers.entrySet()) { Enumeration headerValues = fromIterator(entry.getValue().iterator()); when(this.wrappedRequest.getHeaders(entry.getKey())).thenReturn(headerValues); }/* w w w. j av a2 s. c o m*/ }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * @return return a clone HttpHeader from default HttpHeader *///ww w. j a v a2s . c om private HttpHeaders cloneHttpHeaders() { HttpHeaders httpHeaders = getHttpHeaders(); HttpHeaders clone = new HttpHeaders(); for (String entry : httpHeaders.keySet()) { clone.put(entry, httpHeaders.get(entry)); } return clone; }
From source file:org.springframework.cloud.stream.app.http.source.DefaultMixedCaseContentTypeHttpHeaderMapper.java
/** * Map from an HttpHeaders instance to integration MessageHeaders. * Depending on which type of adapter is using this mapper, the HttpHeaders might be * from an HTTP request (inbound adapter) or from an HTTP response (outbound adapter). *//*from w ww .j a v a2s .c o m*/ @Override public Map<String, Object> toHeaders(HttpHeaders source) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("inboundHeaderNames={0}", CollectionUtils.arrayToList(this.inboundHeaderNames))); } Map<String, Object> target = new HashMap<String, Object>(); Set<String> headerNames = source.keySet(); for (String name : headerNames) { String lowerName = name.toLowerCase(); if (this.shouldMapInboundHeader(lowerName)) { if (!HTTP_REQUEST_HEADER_NAMES_LOWER.contains(lowerName) && !HTTP_RESPONSE_HEADER_NAMES_LOWER.contains(lowerName)) { String prefixedName = StringUtils.startsWithIgnoreCase(name, this.userDefinedHeaderPrefix) ? name : this.userDefinedHeaderPrefix + name; Object value = source.containsKey(prefixedName) ? this.getHttpHeader(source, prefixedName) : this.getHttpHeader(source, name); if (value != null) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value)); } this.setMessageHeader(target, name, value); } } else { Object value = this.getHttpHeader(source, name); if (value != null) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value)); } if (CONTENT_TYPE.equalsIgnoreCase(name)) { name = MessageHeaders.CONTENT_TYPE; } this.setMessageHeader(target, name, value); } } } } return target; }
From source file:org.springframework.integration.http.support.DefaultHttpHeaderMapper.java
/** * Map from an HttpHeaders instance to integration MessageHeaders. * Depending on which type of adapter is using this mapper, the HttpHeaders might be * from an HTTP request (inbound adapter) or from an HTTP response (outbound adapter). *//*from w w w .j a v a 2s .c o m*/ public Map<String, Object> toHeaders(HttpHeaders source) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("inboundHeaderNames={0}", CollectionUtils.arrayToList(inboundHeaderNames))); } Map<String, Object> target = new HashMap<String, Object>(); Set<String> headerNames = source.keySet(); for (String name : headerNames) { if (this.shouldMapInboundHeader(name)) { if (!ObjectUtils.containsElement(HTTP_REQUEST_HEADER_NAMES, name) && !ObjectUtils.containsElement(HTTP_RESPONSE_HEADER_NAMES, name)) { String prefixedName = StringUtils.startsWithIgnoreCase(name, this.userDefinedHeaderPrefix) ? name : this.userDefinedHeaderPrefix + name; Object value = source.containsKey(prefixedName) ? this.getHttpHeader(source, prefixedName) : this.getHttpHeader(source, name); if (value != null) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value)); } this.setMessageHeader(target, name, value); } } else { Object value = this.getHttpHeader(source, name); if (value != null) { if (logger.isDebugEnabled()) { logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value)); } this.setMessageHeader(target, name, value); } } } } return target; }
From source file:org.springframework.web.cors.DefaultCorsProcessor.java
private List<String> getHeadersToUse(ServerHttpRequest request, boolean isPreFlight) { HttpHeaders headers = request.getHeaders(); return (isPreFlight ? headers.getAccessControlRequestHeaders() : new ArrayList<>(headers.keySet())); }