List of usage examples for org.springframework.web.socket WebSocketHttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
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*/ }