/** * 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); }
/** * 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); }
/** * Removes the header with the specified name. */ public static void removeHeader(HttpMessage message, String name) { message.headers().remove(name); }
/** * Removes the {@code "X-SPDY-Scheme"} header. */ public static void removeScheme(HttpMessage message) { message.headers().remove(Names.SCHEME); }
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); } }
private static HttpResponse createHttpResponse(int spdyVersion, SpdyHeadersFrame responseFrame) throws Exception { // Create the first line of the response from the name/value pairs HttpResponseStatus status = SpdyHeaders.getStatus(spdyVersion, responseFrame); HttpVersion version = SpdyHeaders.getVersion(spdyVersion, responseFrame); SpdyHeaders.removeStatus(spdyVersion, responseFrame); SpdyHeaders.removeVersion(spdyVersion, responseFrame); HttpResponse httpResponse = new DefaultHttpResponse(version, status); for (Map.Entry<String, String> e: responseFrame.headers()) { httpResponse.headers().add(e.getKey(), e.getValue()); } // The Connection and Keep-Alive headers are no longer valid HttpHeaders.setKeepAlive(httpResponse, true); // Transfer-Encoding header is not valid httpResponse.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); httpResponse.headers().remove(HttpHeaders.Names.TRAILER); return httpResponse; } }
private SpdySynReplyFrame createSynReplyFrame(HttpResponse httpResponse) throws Exception { boolean chunked = httpResponse.isChunked(); // Get the Stream-ID from the headers int streamId = SpdyHttpHeaders.getStreamId(httpResponse); SpdyHttpHeaders.removeStreamId(httpResponse); // The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding // headers are not valid and MUST not be sent. httpResponse.headers().remove(HttpHeaders.Names.CONNECTION); httpResponse.headers().remove("Keep-Alive"); httpResponse.headers().remove("Proxy-Connection"); httpResponse.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamId); spdySynReplyFrame.setLast(!chunked && !httpResponse.getContent().readable()); // Unfold the first line of the response into name/value pairs SpdyHeaders.setStatus(spdyVersion, spdySynReplyFrame, httpResponse.getStatus()); SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, httpResponse.getProtocolVersion()); // Transfer the remaining HTTP headers for (Map.Entry<String, String> entry: httpResponse.headers()) { spdySynReplyFrame.headers().add(entry.getKey(), entry.getValue()); } return spdySynReplyFrame; }
List<String> transferEncoding = headers.getAll(HttpHeaders.Names.TRANSFER_ENCODING); if (contentTypes != null) { headers.remove(HttpHeaders.Names.CONTENT_TYPE); for (String contentType: contentTypes) { isChunked = true; if (transferEncoding != null) { headers.remove(HttpHeaders.Names.TRANSFER_ENCODING); for (String v: transferEncoding) { if (v.equalsIgnoreCase(HttpHeaders.Values.CHUNKED)) {
httpMessage.headers().remove(HttpHeaders.Names.CONNECTION); httpMessage.headers().remove("Keep-Alive"); httpMessage.headers().remove("Proxy-Connection"); httpMessage.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); httpMessage.headers().remove(HttpHeaders.Names.HOST); SpdyHeaders.setHost(spdySynStreamFrame, host);
private static HttpRequest createHttpRequest(int spdyVersion, SpdyHeadersFrame requestFrame) throws Exception { // Create the first line of the request from the name/value pairs HttpMethod method = SpdyHeaders.getMethod(spdyVersion, requestFrame); String url = SpdyHeaders.getUrl(spdyVersion, requestFrame); HttpVersion httpVersion = SpdyHeaders.getVersion(spdyVersion, requestFrame); SpdyHeaders.removeMethod(spdyVersion, requestFrame); SpdyHeaders.removeUrl(spdyVersion, requestFrame); SpdyHeaders.removeVersion(spdyVersion, requestFrame); HttpRequest httpRequest = new DefaultHttpRequest(httpVersion, method, url); // Remove the scheme header SpdyHeaders.removeScheme(spdyVersion, requestFrame); // Replace the SPDY host header with the HTTP host header String host = SpdyHeaders.getHost(requestFrame); SpdyHeaders.removeHost(requestFrame); HttpHeaders.setHost(httpRequest, host); for (Map.Entry<String, String> e: requestFrame.headers()) { httpRequest.headers().add(e.getKey(), e.getValue()); } // The Connection and Keep-Alive headers are no longer valid HttpHeaders.setKeepAlive(httpRequest, true); // Transfer-Encoding header is not valid httpRequest.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); return httpRequest; }
m.headers().remove(HttpHeaders.Names.CONTENT_LENGTH); } else { ChannelBuffer content = m.getContent();
m.headers().remove(HttpHeaders.Names.CONTENT_ENCODING); } else { m.headers().set(HttpHeaders.Names.CONTENT_ENCODING, targetContentEncoding);
message.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING); resetState(); return message;
encodings.remove(HttpHeaders.Values.CHUNKED); if (encodings.isEmpty()) { m.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING);