@Override public void removeHeaders(String name) { parent.headers().remove(name); }
@Override public String getHeader(String name) { List<String> values = parent.headers().get(name); if (values == null || values.isEmpty()) { return null; } return values.get(values.size() - 1); }
/** * 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); }
public static void copyHeaders(HttpServletRequest from, HttpRequest to) { for (Enumeration<String> it = from.getHeaderNames(); it.hasMoreElements(); ) { String key = it.nextElement(); for (Enumeration<String> value = from.getHeaders(key); value.hasMoreElements(); ) { to.headers().add(key, value.nextElement()); } } }
private static String getFirstHeaderValue(final HttpRequest httpRequest, final String headerName) { final List<String> headerValues = httpRequest.headers().get(headerName); return (headerValues == null || headerValues.isEmpty()) ? "" : headerValues.get(0); }
/** * Access an HTTP header in the request. Multi-value headers are not * supported. * * @param name * the name of an HTTP header * @return the first pertinent value */ public String getHeader(String name) { if (parentRequest.headers().get(name) == null) return null; return parentRequest.headers().get(name).get(0); }
@Override public void copyHeaders(HeaderFields target) { target.addAll(headers()); }
public boolean hasChunkedResponse() { return version == Version.HTTP_1_1 && !headers().isTrue(HttpHeaders.Names.X_DISABLE_CHUNKING); }
@Override public void setHeaders(String name, String value) { parent.headers().put(name, value); }
@Override public void setHeaders(String name, List<String> values) { parent.headers().put(name, values); }
@Override public void addHeader(String name, String value) { parent.headers().add(name, value); }
@Override public void clearCookies() { parent.headers().remove(HttpHeaders.Names.COOKIE); }
public Enumeration<String> getHeaderNames() { return Collections.enumeration(parent.headers().keySet()); }
public List<String> getHeaderNamesAsList() { return new ArrayList<String>(parent.headers().keySet()); }
public List<Cookie> decodeCookieHeader() { List<String> cookies = headers().get(HttpHeaders.Names.COOKIE); if (cookies == null) { return Collections.emptyList(); } List<Cookie> ret = new LinkedList<>(); for (String cookie : cookies) { ret.addAll(Cookie.fromCookieHeader(cookie)); } return ret; }
public void encodeCookieHeader(List<Cookie> cookies) { headers().put(HttpHeaders.Names.COOKIE, Cookie.toCookieHeader(cookies)); }
private Tuple2<HttpResponse, Integer> checkProtocolVersion(HttpRequest request) { return doCheckProtocolVersion(request.getJDiscRequest().headers().get(Headers.VERSION)); }
if (request.getJDiscRequest().headers().get(Headers.DATA_FORMAT) != null) { transferPreviousRepliesToResponse(replies);