Example usage for com.google.common.net HttpHeaders UPGRADE

List of usage examples for com.google.common.net HttpHeaders UPGRADE

Introduction

In this page you can find the example usage for com.google.common.net HttpHeaders UPGRADE.

Prototype

String UPGRADE

To view the source code for com.google.common.net HttpHeaders UPGRADE.

Click Source Link

Document

The HTTP Upgrade header field name.

Usage

From source file:io.kubernetes.client.util.WebSockets.java

/**
 * Create a new WebSocket stream/*from  w  ww. j  a  v  a 2 s .co  m*/
 * @param path The HTTP Path to request from the API
 * @param method The HTTP method to use for the call
 * @param client The ApiClient for communicating with the API
 * @param listener The socket listener to handle socket events
 */
public static void stream(String path, String method, ApiClient client, SocketListener listener)
        throws ApiException, IOException {
    HashMap<String, String> headers = new HashMap<String, String>();
    String allProtocols = String.format("%s,%s,%s,%s", V4_STREAM_PROTOCOL, V3_STREAM_PROTOCOL,
            V2_STREAM_PROTOCOL, V1_STREAM_PROTOCOL);
    headers.put(STREAM_PROTOCOL_HEADER, allProtocols);
    headers.put(HttpHeaders.CONNECTION, HttpHeaders.UPGRADE);
    headers.put(HttpHeaders.UPGRADE, SPDY_3_1);

    Request request = client.buildRequest(path, method, new ArrayList<Pair>(), new ArrayList<Pair>(), null,
            headers, new HashMap<String, Object>(), new String[0], null);
    WebSocketCall.create(client.getHttpClient(), request).enqueue(new Listener(listener));
}