本文整理了Java中io.undertow.websockets.spi.WebSocketHttpExchange.setResponseHeader()
方法的一些代码示例,展示了WebSocketHttpExchange.setResponseHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebSocketHttpExchange.setResponseHeader()
方法的具体详情如下:
包路径:io.undertow.websockets.spi.WebSocketHttpExchange
类名称:WebSocketHttpExchange
方法名:setResponseHeader
[英]Set a response header
[中]设置响应标题
代码示例来源:origin: wildfly/wildfly
/**
* convenience method to perform the upgrade
*/
protected final void performUpgrade(final WebSocketHttpExchange exchange, final byte[] data) {
exchange.setResponseHeader(Headers.CONTENT_LENGTH_STRING, String.valueOf(data.length));
exchange.setResponseHeader(Headers.UPGRADE_STRING, "WebSocket");
exchange.setResponseHeader(Headers.CONNECTION_STRING, "Upgrade");
upgradeChannel(exchange, data);
}
代码示例来源:origin: wildfly/wildfly
/**
* Selects the first matching supported sub protocol and add it the the headers of the exchange.
*
*/
protected final void selectSubprotocol(final WebSocketHttpExchange exchange) {
String requestedSubprotocols = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING);
if (requestedSubprotocols == null) {
return;
}
String[] requestedSubprotocolArray = PATTERN.split(requestedSubprotocols);
String subProtocol = supportedSubprotols(requestedSubprotocolArray);
if (subProtocol != null && !subProtocol.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, subProtocol);
}
}
代码示例来源:origin: wildfly/wildfly
protected final void selectExtensions(final WebSocketHttpExchange exchange) {
List<WebSocketExtension> requestedExtensions = WebSocketExtension.parse(exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING));
List<WebSocketExtension> extensions = selectedExtension(requestedExtensions);
if (extensions != null && !extensions.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, WebSocketExtension.toExtensionHeader(extensions));
}
}
代码示例来源:origin: wildfly/wildfly
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
代码示例来源:origin: io.undertow/undertow-core
/**
* convenience method to perform the upgrade
*/
protected final void performUpgrade(final WebSocketHttpExchange exchange, final byte[] data) {
exchange.setResponseHeader(Headers.CONTENT_LENGTH_STRING, String.valueOf(data.length));
exchange.setResponseHeader(Headers.UPGRADE_STRING, "WebSocket");
exchange.setResponseHeader(Headers.CONNECTION_STRING, "Upgrade");
upgradeChannel(exchange, data);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* convenience method to perform the upgrade
*/
protected final void performUpgrade(final WebSocketHttpExchange exchange, final byte[] data) {
exchange.setResponseHeader(Headers.CONTENT_LENGTH_STRING, String.valueOf(data.length));
exchange.setResponseHeader(Headers.UPGRADE_STRING, "WebSocket");
exchange.setResponseHeader(Headers.CONNECTION_STRING, "Upgrade");
upgradeChannel(exchange, data);
}
代码示例来源:origin: io.undertow/undertow-core
/**
* Selects the first matching supported sub protocol and add it the the headers of the exchange.
*
*/
protected final void selectSubprotocol(final WebSocketHttpExchange exchange) {
String requestedSubprotocols = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING);
if (requestedSubprotocols == null) {
return;
}
String[] requestedSubprotocolArray = PATTERN.split(requestedSubprotocols);
String subProtocol = supportedSubprotols(requestedSubprotocolArray);
if (subProtocol != null && !subProtocol.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, subProtocol);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Selects the first matching supported sub protocol and add it the the headers of the exchange.
*
*/
protected final void selectSubprotocol(final WebSocketHttpExchange exchange) {
String requestedSubprotocols = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING);
if (requestedSubprotocols == null) {
return;
}
String[] requestedSubprotocolArray = PATTERN.split(requestedSubprotocols);
String subProtocol = supportedSubprotols(requestedSubprotocolArray);
if (subProtocol != null && !subProtocol.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, subProtocol);
}
}
代码示例来源:origin: io.undertow/undertow-core
protected final void selectExtensions(final WebSocketHttpExchange exchange) {
List<WebSocketExtension> requestedExtensions = WebSocketExtension.parse(exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING));
List<WebSocketExtension> extensions = selectedExtension(requestedExtensions);
if (extensions != null && !extensions.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, WebSocketExtension.toExtensionHeader(extensions));
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected final void selectExtensions(final WebSocketHttpExchange exchange) {
List<WebSocketExtension> requestedExtensions = WebSocketExtension.parse(exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING));
List<WebSocketExtension> extensions = selectedExtension(requestedExtensions);
if (extensions != null && !extensions.isEmpty()) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, WebSocketExtension.toExtensionHeader(extensions));
}
}
代码示例来源:origin: io.undertow/undertow-core
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
代码示例来源:origin: io.undertow/undertow-core
@Override
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
@Override
protected void handshakeInternal(final WebSocketHttpExchange exchange) {
String origin = exchange.getRequestHeader(Headers.ORIGIN_STRING);
if (origin != null) {
exchange.setResponseHeader(Headers.ORIGIN_STRING, origin);
}
selectSubprotocol(exchange);
selectExtensions(exchange);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange));
final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING);
try {
final String solution = solve(key);
exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, solution);
performUpgrade(exchange);
} catch (NoSuchAlgorithmException e) {
IoUtils.safeClose(exchange);
exchange.endExchange();
return;
}
}
内容来源于网络,如有侵权,请联系作者删除!