/** * Sets the {@code "Host"} header. */ public static void setHost(HttpMessage message, String value) { message.headers().set(Names.HOST, value); }
/** * 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); }
/** * Sets the {@code "X-SPDY-URL"} header. */ public static void setUrl(HttpMessage message, String url) { message.headers().set(Names.URL, url); }
/** * Sets the {@code "Content-Length"} header. */ public static void setContentLength(HttpMessage message, long length) { message.headers().set(Names.CONTENT_LENGTH, length); }
/** * 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); }
/** * Sets the {@code "X-SPDY-Scheme"} header. */ public static void setScheme(HttpMessage message, String scheme) { message.headers().set(Names.SCHEME, scheme); } }
/** * Sets a new header with the specified name and value. If there is an * existing header with the same name, the existing header is removed. * 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 setHeader(HttpMessage message, String name, Object value) { message.headers().set(name, value); }
/** * Sets a new integer header with the specified name and values. If there * is an existing header with the same name, the existing header is removed. */ public static void setIntHeader(HttpMessage message, String name, Iterable<Integer> values) { message.headers().set(name, values); }
/** * Sets a new header with the specified name and values. If there is an * existing header with the same name, the existing header is removed. * This getMethod can be represented approximately as the following code: * <pre> * removeHeader(message, name); * for (Object v: values) { * if (v == null) { * break; * } * addHeader(message, name, v); * } * </pre> */ public static void setHeader(HttpMessage message, String name, Iterable<?> values) { message.headers().set(name, values); }
/** * Sets a new date header with the specified name and value. If there * is an existing header with the same name, the existing header is removed. * 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 setDateHeader(HttpMessage message, String name, Date value) { if (value != null) { message.headers().set(name, HttpHeaderDateFormat.get().format(value)); } else { message.headers().set(name, null); } }
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); } }
/** * Sets or removes the {@code "Expect: 100-continue"} header to / from the * specified message. If the specified {@code value} is {@code true}, * the {@code "Expect: 100-continue"} header is set and all other previous * {@code "Expect"} headers are removed. Otherwise, all {@code "Expect"} * headers are removed completely. */ public static void set100ContinueExpected(HttpMessage message, boolean set) { if (set) { message.headers().set(Names.EXPECT, Values.CONTINUE); } else { message.headers().remove(Names.EXPECT); } }
/** * Return that we need cannot not support the web socket version * * @param channel * Channel */ public ChannelFuture sendUnsupportedWebSocketVersionResponse(Channel channel) { HttpResponse res = new DefaultHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.SWITCHING_PROTOCOLS); res.setStatus(HttpResponseStatus.UPGRADE_REQUIRED); res.headers().set(Names.SEC_WEBSOCKET_VERSION, WebSocketVersion.V13.toHttpHeaderValue()); return channel.write(res); }
HttpVersion.HTTP_1_1, HttpMethod.POST, serverPath); if (serverName != null) { req.headers().set(HttpHeaders.Names.HOST, serverName); req.headers().set(HttpHeaders.Names.CONTENT_TYPE, "application/octet-stream"); req.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED); req.headers().set(HttpHeaders.Names.CONTENT_TRANSFER_ENCODING, HttpHeaders.Values.BINARY); req.headers().set(HttpHeaders.Names.USER_AGENT, HttpTunnelingClientSocketChannel.class.getName());
iterator = multipartHttpDatas.listIterator(); headers.set(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(realSize)); if (realSize > HttpPostBodyUtil.chunkSize || isMultipart) { isChunked = true;
httpRequest.headers().set(HttpHeaders.Names.ACCEPT_ENCODING, compressionCodec.getEncodingString());