@Override public List<String> apply(String input) { return headers.getAll(input); } }));
static boolean isTransferEncodingChunked(HttpMessage m) { List<String> chunked = m.headers().getAll(HttpHeaders.Names.TRANSFER_ENCODING); if (chunked.isEmpty()) { return false; } for (String v: chunked) { if (v.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) { return true; } } return false; }
static boolean isContentLengthSet(HttpMessage m) { List<String> contentLength = m.headers().getAll(HttpHeaders.Names.CONTENT_LENGTH); return !contentLength.isEmpty(); }
/** * Returns {@code true} if a header with the name and value exists. * * @param name the headername * @param value the value * @param ignoreCaseValue {@code true} if case should be ignored * @return contains {@code true} if it contains it {@code false} otherwise */ public boolean contains(String name, String value, boolean ignoreCaseValue) { List<String> values = getAll(name); if (values.isEmpty()) { return false; } for (String v: values) { if (ignoreCaseValue) { if (v.equalsIgnoreCase(value)) { return true; } } else { if (v.equals(value)) { return true; } } } return false; } }
public static void removeTransferEncodingChunked(HttpMessage m) { List<String> values = m.headers().getAll(Names.TRANSFER_ENCODING); if (values.isEmpty()) { return; } Iterator<String> valuesIt = values.iterator(); while (valuesIt.hasNext()) { String value = valuesIt.next(); if (value.equalsIgnoreCase(Values.CHUNKED)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(Names.TRANSFER_ENCODING); } else { m.headers().set(Names.TRANSFER_ENCODING, values); } }
static void removeTransferEncodingChunked(HttpMessage m) { List<String> values = m.headers().getAll(HttpHeaders.Names.TRANSFER_ENCODING); if (values.isEmpty()) { return; } Iterator<String> valuesIt = values.iterator(); while (valuesIt.hasNext()) { String value = valuesIt.next(); if (value.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) { valuesIt.remove(); } } if (values.isEmpty()) { m.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); } else { m.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, values); } }
char firstChar = line.charAt(0); if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) { List<String> current = trailer.trailingHeaders().getAll(lastHeader); if (!current.isEmpty()) { int lastPos = current.size() - 1;
@Override public List<String> get(Object key) { return key instanceof String ? httpHeaders.getAll((String) key) : null; }
List<String> proxyAuthHeaders = response.headers().getAll(HttpHeaders.Names.PROXY_AUTHENTICATE);
List<String> authHeaders = response.headers().getAll(HttpHeaders.Names.WWW_AUTHENTICATE);
private static List<BBoshStrategy> readAcceptStrategies(HttpHeaders httpHeaders) { List<String> strategyValues = httpHeaders.getAll(Names.X_ACCEPT_STRATEGY); List<BBoshStrategy> strategies = new ArrayList<>(3); for (String strategyValue : strategyValues) { String[] strategyValueParts = strategyValue.split(",\\s+"); for (String strategyValuePart : strategyValueParts) { BBoshStrategy strategy = BBoshStrategy.valueOf(strategyValuePart); strategies.add(strategy); } } return strategies; }
@Override public Set<Entry<String, List<String>>> entrySet() { return httpHeaders.names().stream() .map(k -> new AbstractMap.SimpleImmutableEntry<>(k, httpHeaders.getAll(k))).collect(Collectors.toSet()); } }
@Override public Collection<List<String>> values() { return httpHeaders.names().stream().map(k -> Collections.unmodifiableList(httpHeaders.getAll(k))).collect(Collectors.toList()); }
protected static Map<String, Http.Header> getHeaders(HttpRequest nettyRequest) { Map<String, Http.Header> headers = new HashMap<>(16); for (String key : nettyRequest.headers().names()) { Http.Header hd = new Http.Header(); hd.name = key.toLowerCase(); hd.values = new ArrayList<>(); for (String next : nettyRequest.headers().getAll(key)) { hd.values.add(next); } headers.put(hd.name, hd); } return headers; }
for (String cookieStr : responseHeaders.getAll(HttpHeaders.Names.SET_COOKIE)) { Cookie c = CookieDecoder.decode(cookieStr); if (c != null)
@Override public boolean decode(Channel channel) throws Exception { HttpChannelConfig httpConfig = (HttpChannelConfig) channel.getConfig(); HttpHeaders headers = httpConfig.getReadHeaders(); List<String> headerValues = headers.getAll(name); if (!headerValues.isEmpty()) { throw new ScriptProgressException(getRegionInfo(), format("HTTP header not missing: %s", name)); } return true; }
@Override public boolean decode(Channel channel) throws Exception { HttpChannelConfig httpConfig = (HttpChannelConfig) channel.getConfig(); HttpHeaders headers = httpConfig.getReadHeaders(); List<String> headerValues = headers.getAll(name); if (valueDecoders.size() == 1) { MessageDecoder valueDecoder = valueDecoders.get(0); decodeHeaderValue(headers, headerValues, valueDecoder); } else { for (MessageDecoder valueDecoder : valueDecoders) { decodeHeaderValue(headers, headerValues, valueDecoder); } } return true; }
@Override public boolean decode(Channel channel) throws Exception { HttpChannelConfig httpConfig = (HttpChannelConfig) channel.getConfig(); HttpHeaders headers = httpConfig.getReadTrailers(); List<String> headerValues = headers.getAll(name); if (valueDecoders.size() == 1) { MessageDecoder valueDecoder = valueDecoders.get(0); decodeTrailerValue(headers, headerValues, valueDecoder); } else { for (MessageDecoder valueDecoder : valueDecoders) { decodeTrailerValue(headers, headerValues, valueDecoder); } } return true; }
@Override public void populateCamelHeaders(HttpResponse response, Map<String, Object> headers, Exchange exchange, NettyHttpConfiguration configuration) throws Exception { LOG.trace("populateCamelHeaders: {}", response); headers.put(Exchange.HTTP_RESPONSE_CODE, response.getStatus().getCode()); headers.put(Exchange.HTTP_RESPONSE_TEXT, response.getStatus().getReasonPhrase()); for (String name : response.headers().names()) { // mapping the content-type if (name.toLowerCase().equals("content-type")) { name = Exchange.CONTENT_TYPE; } // add the headers one by one, and use the header filter strategy List<String> values = response.headers().getAll(name); Iterator<?> it = ObjectHelper.createIterator(values); while (it.hasNext()) { Object extracted = it.next(); LOG.trace("HTTP-header: {}", extracted); if (headerFilterStrategy != null && !headerFilterStrategy.applyFilterToExternalHeaders(name, extracted, exchange)) { NettyHttpHelper.appendHeader(headers, name, extracted); } } } }