Java Code Examples for org.springframework.web.socket.WebSocketHttpHeaders#getSecWebSocketProtocol()

The following examples show how to use org.springframework.web.socket.WebSocketHttpHeaders#getSecWebSocketProtocol() . 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: AbstractWebSocketClient.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
		@Nullable WebSocketHttpHeaders headers, URI uri) {

	Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
	assertUri(uri);

	if (logger.isDebugEnabled()) {
		logger.debug("Connecting to " + uri);
	}

	HttpHeaders headersToUse = new HttpHeaders();
	if (headers != null) {
		headers.forEach((header, values) -> {
			if (values != null && !specialHeaders.contains(header.toLowerCase())) {
				headersToUse.put(header, values);
			}
		});
	}

	List<String> subProtocols =
			(headers != null ? headers.getSecWebSocketProtocol() : Collections.emptyList());
	List<WebSocketExtension> extensions =
			(headers != null ? headers.getSecWebSocketExtensions() : Collections.emptyList());

	return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
			Collections.emptyMap());
}
 
Example 2
Source File: AbstractWebSocketClient.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
		@Nullable WebSocketHttpHeaders headers, URI uri) {

	Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
	assertUri(uri);

	if (logger.isDebugEnabled()) {
		logger.debug("Connecting to " + uri);
	}

	HttpHeaders headersToUse = new HttpHeaders();
	if (headers != null) {
		headers.forEach((header, values) -> {
			if (values != null && !specialHeaders.contains(header.toLowerCase())) {
				headersToUse.put(header, values);
			}
		});
	}

	List<String> subProtocols =
			(headers != null ? headers.getSecWebSocketProtocol() : Collections.emptyList());
	List<WebSocketExtension> extensions =
			(headers != null ? headers.getSecWebSocketExtensions() : Collections.emptyList());

	return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
			Collections.emptyMap());
}
 
Example 3
Source File: AbstractWebSocketClient.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
		WebSocketHttpHeaders headers, URI uri) {

	Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
	assertUri(uri);

	if (logger.isDebugEnabled()) {
		logger.debug("Connecting to " + uri);
	}

	HttpHeaders headersToUse = new HttpHeaders();
	if (headers != null) {
		for (String header : headers.keySet()) {
			if (!specialHeaders.contains(header.toLowerCase())) {
				headersToUse.put(header, headers.get(header));
			}
		}
	}

	List<String> subProtocols = ((headers != null) && (headers.getSecWebSocketProtocol() != null)) ?
			headers.getSecWebSocketProtocol() : Collections.<String>emptyList();

	List<WebSocketExtension> extensions = ((headers != null) && (headers.getSecWebSocketExtensions() != null)) ?
			headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList();

	return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
			Collections.<String, Object>emptyMap());
}