/** * <p>Adds the given values to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given values.</p> * * @param key The key with which the specified value is to be associated. * @param values The values to be added to the list associated with the specified key. */ public void add(String key, List<String> values) { h.add(key, values); }
@Override public List<String> get(Object key) { return h.get(key); }
/** * <p>Convenience method to call {@link #put(String, List)} with a singleton list that contains the specified * value.</p> * * @param key The key of the entry to put. * @param value The value to put. * @return The previous value associated with <code>key</code>, or <code>null</code> if there was no mapping for * <code>key</code>. */ public List<String> put(String key, String value) { return h.put(key, value); }
public ServletRequest(HttpServletRequest request, URI uri) { super(request); this.request = request; this.uri = uri; super.getParameterMap().forEach( (key, values) -> parameters.put(key, Arrays.asList(values))); remoteHostAddress = request.getRemoteAddr(); remoteHostName = request.getRemoteHost(); remotePort = request.getRemotePort(); connectedAt = getConnection(request).getCreatedTimeStamp(); headerFields = new HeaderFields(); Enumeration<String> parentHeaders = request.getHeaderNames(); while (parentHeaders.hasMoreElements()) { String name = parentHeaders.nextElement(); Enumeration<String> values = request.getHeaders(name); while (values.hasMoreElements()) { headerFields.add(name, values.nextElement()); } } }
private void addResponseHeaders(HttpResponse httpResponse, long startTime) { if ( ! httpResponse.headers().containsKey(CONTENT_TYPE) && httpResponse.getContentType() != null) { StringBuilder s = new StringBuilder(httpResponse.getContentType()); if (httpResponse.getCharacterEncoding() != null) { s.append("; charset=").append(httpResponse.getCharacterEncoding()); } httpResponse.headers().put(CONTENT_TYPE, s.toString()); } addDateHeader(httpResponse, startTime); }
/** * <p>Adds all the entries of the given map to this. This is the same as calling {@link #add(String, List)} for each * entry in <code>values</code>.</p> * * @param values The values to be added to this. */ public void addAll(Map<? extends String, ? extends List<String>> values) { h.addAll(values); }
public boolean isChunkedEncodingEnabled() { if (headers().contains(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED)) { return true; } if (headers().containsKey(HttpHeaders.Names.CONTENT_LENGTH)) { return false; } return chunkedEncodingEnabled; }
@Override public boolean containsKey(Object key) { return h.containsKey(key); }
/** * <p>Convenience method for checking whether or not a named header contains a specific value, regardless of case. * If the named header is not set, or if the given value is not contained within that header's value list, this * method returns <em>false</em>.</p> * * <p><em>NOTE:</em> This method is case-INSENSITIVE.</p> * * @param key The key whose values to search in. * @param value The values to search for, ignoring case. * @return True if the given value was found in the named header. * @see #contains */ public boolean containsIgnoreCase(String key, String value) { return h.containsIgnoreCase(key, value); }
/** * <p>Convenience method for checking whether or not a named header contains a specific value. If the named header * is not set, or if the given value is not contained within that header's value list, this method returns * <em>false</em>.</p> * * <p><em>NOTE:</em> This method is case-SENSITIVE.</p> * * @param key The key whose values to search in. * @param value The values to search for. * @return True if the given value was found in the named header. * @see #containsIgnoreCase */ public boolean contains(String key, String value) { return h.contains(key, value); }
@Override public void copyHeaders(HeaderFields target) { target.addAll(headerFields); }
/** * Returns whether this request was <em>explicitly</em> chunked from the client. NOTE that there are cases * where the underlying HTTP server library (Netty for the time being) will read the request in a chunked manner. An * application MUST wait for {@link com.yahoo.jdisc.handler.ContentChannel#close(com.yahoo.jdisc.handler.CompletionHandler)} * before it can actually know that it has received the entire request. * * @return true if this request was chunked from the client. */ public boolean isChunked() { return version == Version.HTTP_1_1 && headers().containsIgnoreCase(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED); }
/** * <p>Adds the given value to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given value.</p> * * @param key The key with which the specified value is to be associated. * @param value The value to be added to the list associated with the specified key. */ public void add(String key, String value) { h.add(key, value); }
@Override public List<String> put(String key, List<String> value) { return h.put(key, value); }
public static boolean benchmarkCoverage(boolean benchmarkOutput, HeaderFields headers) { if (benchmarkOutput && headers.get(BenchmarkingHeaders.REQUEST_COVERAGE) != null) { return true; } else { return false; } }
@Override public void copyHeaders(HeaderFields target) { target.addAll(headers()); }
public boolean isKeepAlive() { if (headers().containsIgnoreCase(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE)) { return true; } if (headers().containsIgnoreCase(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE)) { return false; } return version == Version.HTTP_1_1; }
public void addHeader(String name, String value) { headerFields.add(name, value); headerBlacklist.remove(name); }
public void setHeaders(String name, List<String> values) { headerFields.put(name, values); headerBlacklist.remove(name); }