@Override public HttpVersion protocolVersion() { return message.protocolVersion(); }
@Override public HttpVersion protocolVersion() { return message.protocolVersion(); }
@Override public HttpVersion getProtocolVersion() { return message.protocolVersion(); }
@Override public HttpVersion protocolVersion() { return message.protocolVersion(); }
@Override @Deprecated public HttpVersion getProtocolVersion() { return message.protocolVersion(); }
@Override @Deprecated public HttpVersion getProtocolVersion() { return message.protocolVersion(); }
private static boolean isExpectHeaderValid(final HttpMessage message) { /* * Expect: 100-continue is for requests only and it works only on HTTP/1.1 or later. Note further that RFC 7231 * section 5.1.1 says "A server that receives a 100-continue expectation in an HTTP/1.0 request MUST ignore * that expectation." */ return message instanceof HttpRequest && message.protocolVersion().compareTo(HttpVersion.HTTP_1_1) >= 0; }
private static void appendCommon(StringBuilder buf, HttpMessage msg) { buf.append(StringUtil.simpleClassName(msg)); buf.append("(decodeResult: "); buf.append(msg.decoderResult()); buf.append(", version: "); buf.append(msg.protocolVersion()); buf.append(')'); buf.append(StringUtil.NEWLINE); }
/** * Sets the value of the {@code "Connection"} header depending on the * protocol version of the specified message. This getMethod sets or removes * the {@code "Connection"} header depending on what the default keep alive * mode of the message's protocol version is, as specified by * {@link HttpVersion#isKeepAliveDefault()}. * <ul> * <li>If the connection is kept alive by default: * <ul> * <li>set to {@code "close"} if {@code keepAlive} is {@code false}.</li> * <li>remove otherwise.</li> * </ul></li> * <li>If the connection is closed by default: * <ul> * <li>set to {@code "keep-alive"} if {@code keepAlive} is {@code true}.</li> * <li>remove otherwise.</li> * </ul></li> * </ul> * @see #setKeepAlive(HttpHeaders, HttpVersion, boolean) */ public static void setKeepAlive(HttpMessage message, boolean keepAlive) { setKeepAlive(message.headers(), message.protocolVersion(), keepAlive); }
/** * Returns {@code true} if and only if the connection can remain open and * thus 'kept alive'. This methods respects the value of the. * {@code "Connection"} header first and then the return value of * {@link HttpVersion#isKeepAliveDefault()}. */ public static boolean isKeepAlive(HttpMessage message) { CharSequence connection = message.headers().get(HttpHeaderNames.CONNECTION); if (connection != null && HttpHeaderValues.CLOSE.contentEqualsIgnoreCase(connection)) { return false; } if (message.protocolVersion().isKeepAliveDefault()) { return !HttpHeaderValues.CLOSE.contentEqualsIgnoreCase(connection); } else { return HttpHeaderValues.KEEP_ALIVE.contentEqualsIgnoreCase(connection); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. if (LOGGER.isWarnEnabled()) { LOGGER.warn("Directly talking: {} (no upgrade was attempted) from {}", msg.protocolVersion(), NetUtil.toSocketAddressString(ch.remoteAddress())); } ChannelPipeline pipeline = ctx.pipeline(); ChannelHandlerContext thisCtx = pipeline.context(this); // 不需要了 pipeline.addAfter(bizGroup, thisCtx.name(), "Http1ChannelHandler", new Http1ServerChannelHandler(serverHandler)); pipeline.replace(this, "HttpObjectAggregator", new HttpObjectAggregator(maxHttpContentLength)); // HttpServerUpgradeHandler -> HttpServerCodec -> HttpObjectAggregator -> Http1ChannelHandler, ctx.fireChannelRead(ReferenceCountUtil.retain(msg)); } });
@Override protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception { // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP. if (LOGGER.isWarnEnabled()) { LOGGER.warn("Directly talking: {} (no upgrade was attempted) from {}", msg.protocolVersion(), NetUtil.toSocketAddressString(ch.remoteAddress())); } ChannelPipeline pipeline = ctx.pipeline(); ChannelHandlerContext thisCtx = pipeline.context(this); // 不需要了 pipeline.addAfter(bizGroup, thisCtx.name(), "Http1ChannelHandler", new Http1ServerChannelHandler(serverHandler)); pipeline.replace(this, "HttpObjectAggregator", new HttpObjectAggregator(maxHttpContentLength)); // HttpServerUpgradeHandler -> HttpServerCodec -> HttpObjectAggregator -> Http1ChannelHandler, ctx.fireChannelRead(ReferenceCountUtil.retain(msg)); } });
@Override public HttpVersion protocolVersion() { return message.protocolVersion(); }
@Override public HttpVersion getProtocolVersion() { return message.protocolVersion(); }
private static boolean isExpectHeaderValid(final HttpMessage message) { /* * Expect: 100-continue is for requests only and it works only on HTTP/1.1 or later. Note further that RFC 7231 * section 5.1.1 says "A server that receives a 100-continue expectation in an HTTP/1.0 request MUST ignore * that expectation." */ return message instanceof HttpRequest && message.protocolVersion().compareTo(HttpVersion.HTTP_1_1) >= 0; }
private static boolean isExpectHeaderValid(final HttpMessage message) { /* * Expect: 100-continue is for requests only and it works only on HTTP/1.1 or later. Note further that RFC 7231 * section 5.1.1 says "A server that receives a 100-continue expectation in an HTTP/1.0 request MUST ignore * that expectation." */ return message instanceof HttpRequest && message.protocolVersion().compareTo(HttpVersion.HTTP_1_1) >= 0; }
private static boolean isExpectHeaderValid(final HttpMessage message) { /* * Expect: 100-continue is for requests only and it works only on HTTP/1.1 or later. Note further that RFC 7231 * section 5.1.1 says "A server that receives a 100-continue expectation in an HTTP/1.0 request MUST ignore * that expectation." */ return message instanceof HttpRequest && message.protocolVersion().compareTo(HttpVersion.HTTP_1_1) >= 0; }
private static void appendCommon(StringBuilder buf, HttpMessage msg) { buf.append(StringUtil.simpleClassName(msg)); buf.append("(decodeResult: "); buf.append(msg.decoderResult()); buf.append(", version: "); buf.append(msg.protocolVersion()); buf.append(')'); buf.append(StringUtil.NEWLINE); }
private static void appendCommon(StringBuilder buf, HttpMessage msg) { buf.append(StringUtil.simpleClassName(msg)); buf.append("(decodeResult: "); buf.append(msg.decoderResult()); buf.append(", version: "); buf.append(msg.protocolVersion()); buf.append(')'); buf.append(StringUtil.NEWLINE); }
private static void appendCommon(StringBuilder buf, HttpMessage msg) { buf.append(StringUtil.simpleClassName(msg)); buf.append("(decodeResult: "); buf.append(msg.decoderResult()); buf.append(", version: "); buf.append(msg.protocolVersion()); buf.append(')'); buf.append(StringUtil.NEWLINE); }