Example usage for org.springframework.web.socket WebSocketHttpHeaders add

List of usage examples for org.springframework.web.socket WebSocketHttpHeaders add

Introduction

In this page you can find the example usage for org.springframework.web.socket WebSocketHttpHeaders add.

Prototype

@Override
public void add(String headerName, @Nullable String headerValue) 

Source Link

Document

Add the given, single header value under the given name.

Usage

From source file:gr.abiss.calipso.test.AbstractControllerIT.java

protected StompSession getStompSession(String url, Loggedincontext loginContext,
        StompSessionHandler sessionHandler, WebSocketHttpHeaders handshakeHeaders,
        StompHeaders connectHeaders) {//  w  w w  .  j  a  v a2 s . com
    if (sessionHandler == null) {
        sessionHandler = new DefaultStompSessionHandler();
    }
    StompSession ownerSession = null;

    // add auth
    if (handshakeHeaders == null) {
        handshakeHeaders = new WebSocketHttpHeaders();
    }
    handshakeHeaders.add("Authorization", "Basic " + loginContext.ssoToken);

    try {
        ownerSession = getWebSocketStompClient().connect(url, handshakeHeaders, connectHeaders, sessionHandler)
                .get(1, SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        throw new RuntimeException(e);
    }

    return ownerSession;
}

From source file:org.springframework.web.socket.sockjs.client.AbstractSockJsIntegrationTests.java

@Test
public void echoXhrWithHeaders() throws Exception {
    AbstractXhrTransport xhrTransport = createXhrTransport();
    xhrTransport.setXhrStreamingDisabled(true);

    WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
    headers.add("auth", "123");
    testEcho(10, xhrTransport, headers);

    for (Map.Entry<String, HttpHeaders> entry : this.testFilter.requests.entrySet()) {
        HttpHeaders httpHeaders = entry.getValue();
        assertEquals("No auth header for: " + entry.getKey(), "123", httpHeaders.getFirst("auth"));
    }/*from   w  ww  .  j a  v a2  s .co m*/
}