Example usage for io.vertx.core.http HttpVersion HTTP_1_1

List of usage examples for io.vertx.core.http HttpVersion HTTP_1_1

Introduction

In this page you can find the example usage for io.vertx.core.http HttpVersion HTTP_1_1.

Prototype

HttpVersion HTTP_1_1

To view the source code for io.vertx.core.http HttpVersion HTTP_1_1.

Click Source Link

Usage

From source file:io.apiman.gateway.platforms.vertx3.http.HttpApiFactory.java

License:Apache License

public static void buildResponse(HttpServerResponse httpServerResponse, ApiResponse amanResponse,
        HttpVersion httpVersion) {//ww w.  ja va 2  s .  c  om
    amanResponse.getHeaders().forEach(e -> {
        if (httpVersion == HttpVersion.HTTP_1_0 || httpVersion == HttpVersion.HTTP_1_1
                || !e.getKey().equals("Connection")) {
            httpServerResponse.headers().add(e.getKey(), e.getValue());
        }
    });
    httpServerResponse.setStatusCode(amanResponse.getCode());
    httpServerResponse.setStatusMessage(amanResponse.getMessage());
}

From source file:org.wisdom.framework.vertx.HttpUtils.java

License:Apache License

/**
 * Checks whether the given request should be closed or not once completed.
 *
 * @param request the request/*from w w  w .  j a  v a2  s. c o  m*/
 * @return {@code true} if the connection is marked as {@literal keep-alive}, and so must not be closed. {@code
 * false} otherwise. Notice that if not set in the request, the default value depends on the HTTP version.
 */
public static boolean isKeepAlive(HttpServerRequest request) {
    String connection = request.headers().get(HeaderNames.CONNECTION);
    if (connection != null && connection.equalsIgnoreCase(CLOSE)) {
        return false;
    }
    if (request.version() == HttpVersion.HTTP_1_1) {
        return !CLOSE.equalsIgnoreCase(connection);
    } else {
        return KEEP_ALIVE.equalsIgnoreCase(connection);
    }
}