Java Code Examples for io.netty.handler.codec.http.HttpVersion#equals()

The following examples show how to use io.netty.handler.codec.http.HttpVersion#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyHttpResponse.java    From netstrap with Apache License 2.0 6 votes vote down vote up
/**
 * 设置keep-alive
 */
public HttpResponse keepAlive(HttpVersion httpVersion, Map<String, String> header) {

    String connection = header.getOrDefault(HeaderPublicKey.CONNECTION, Keepalive.CLOSE_ALIVE).toLowerCase();

    //设置keep-alive
    if ((httpVersion.equals(HttpVersion.HTTP_1_1) && !connection.equals(Keepalive.CLOSE_ALIVE))) {
        setKeepAlive(true);
    } else if (httpVersion.equals(HttpVersion.HTTP_1_0) && connection.equals(Keepalive.KEEP_ALIVE)) {
        setKeepAlive(true);
    }

    if (isKeepAlive()) {
        addHeader(HeaderPublicKey.CONNECTION, Keepalive.KEEP_ALIVE);
    }

    return this;
}
 
Example 2
Source File: ThriftMarshaller.java    From xio with Apache License 2.0 5 votes vote down vote up
private Http1Version build(HttpVersion version) {
  if (version != null) {
    if (version.equals(HttpVersion.HTTP_1_0)) {
      return Http1Version.HTTP_1_0;
    } else if (version.equals(HttpVersion.HTTP_1_1)) {
      return Http1Version.HTTP_1_1;
    }
  }
  return null;
}
 
Example 3
Source File: Headers.java    From crate with Apache License 2.0 4 votes vote down vote up
public static void setKeepAlive(HttpVersion httpVersion, FullHttpResponse resp) {
    if (httpVersion.equals(HttpVersion.HTTP_1_0)) {
        resp.headers().add(HttpHeaderNames.CONNECTION, "Keep-Alive");
    }
}