/** * Sets the {@code "Host"} header. */ public static void setHost(HttpMessage message, String value) { message.headers().set(Names.HOST, value); }
/** * Removes the {@code "X-SPDY-Priority"} header. */ public static void removePriority(HttpMessage message) { message.headers().remove(Names.PRIORITY); }
/** * Removes the {@code "X-SPDY-URL"} header. */ public static void removeUrl(HttpMessage message) { message.headers().remove(Names.URL); }
/** * Sets the {@code "X-SPDY-URL"} header. */ public static void setUrl(HttpMessage message, String url) { message.headers().set(Names.URL, url); }
/** * Returns the value of the {@code "X-SPDY-Scheme"} header. */ public static String getScheme(HttpMessage message) { return message.headers().get(Names.SCHEME); }
/** * Adds a new header with the specified name and value. * If the specified value is not a {@link String}, it is converted into a * {@link String} by {@link Object#toString()}, except for {@link Date} * and {@link Calendar} which are formatted to the date format defined in * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>. */ public static void addHeader(HttpMessage message, String name, Object value) { message.headers().add(name, value); }
/** * Removes the header with the specified name. */ public static void removeHeader(HttpMessage message, String name) { message.headers().remove(name); }
/** * Adds a new integer header with the specified name and value. */ public static void addIntHeader(HttpMessage message, String name, int value) { message.headers().add(name, value); }
/** * Sets the {@code "Content-Length"} header. */ public static void setContentLength(HttpMessage message, long length) { message.headers().set(Names.CONTENT_LENGTH, length); }
/** * Removes all headers from the specified message. */ public static void clearHeaders(HttpMessage message) { message.headers().clear(); }
/** * Sets a new date header with the specified name and values. If there * is an existing header with the same name, the existing header is removed. * The specified values are formatted as defined in * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a> */ public static void setDateHeader(HttpMessage message, String name, Iterable<Date> values) { message.headers().set(name, values); }
/** * Adds a new date header with the specified name and value. The specified * value is formatted as defined in * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a> */ public static void addDateHeader(HttpMessage message, String name, Date value) { message.headers().add(name, value); }
/** * Removes the {@code "X-SPDY-Stream-ID"} header. */ public static void removeStreamId(HttpMessage message) { message.headers().remove(Names.STREAM_ID); }
/** * Removes the {@code "X-SPDY-Associated-To-Stream-ID"} header. */ public static void removeAssociatedToStreamId(HttpMessage message) { message.headers().remove(Names.ASSOCIATED_TO_STREAM_ID); }
/** * Sets a new integer header with the specified name and value. If there * is an existing header with the same name, the existing header is removed. */ public static void setIntHeader(HttpMessage message, String name, int value) { message.headers().set(name, value); }
/** * Checks to see if the transfer encoding in a specified {@link HttpMessage} is chunked * * @param message The message to check * @return True if transfer encoding is chunked, otherwise false */ public static boolean isTransferEncodingChunked(HttpMessage message) { return message.headers().contains(Names.TRANSFER_ENCODING, Values.CHUNKED, true); }
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(); }
private static void encodeHeaders(ChannelBuffer buf, HttpMessage message) { try { for (Map.Entry<String, String> h: message.headers()) { encodeHeader(buf, h.getKey(), h.getValue()); } } catch (UnsupportedEncodingException e) { throw (Error) new Error().initCause(e); } }