本文整理了Java中org.glassfish.tyrus.core.Utils.getHeaderFromList()
方法的一些代码示例,展示了Utils.getHeaderFromList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getHeaderFromList()
方法的具体详情如下:
包路径:org.glassfish.tyrus.core.Utils
类名称:Utils
方法名:getHeaderFromList
[英]Creates single String value from provided List by calling Object#toString() on each item and separating existing ones with ", ".
[中]通过对每个项调用对象#toString()并用“,”分隔现有项,从提供的列表中创建单个字符串值。
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
Writer servletWriter = newServletWriter(handler);
handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
response.flushBuffer();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
AsyncContext asyncContext = request.startAsync();
asyncContext.setTimeout(-1L);
Object nativeRequest = getNativeRequest(request);
BeanWrapper beanWrapper = new BeanWrapperImpl(nativeRequest);
Object httpSocket = beanWrapper.getPropertyValue("connection.connectionHandler.rawConnection");
Object webSocket = webSocketHelper.newInstance(request, httpSocket);
webSocketHelper.upgrade(webSocket, httpSocket, request.getServletContext());
response.flushBuffer();
boolean isProtected = request.getUserPrincipal() != null;
Writer servletWriter = servletWriterHelper.newInstance(webSocket, isProtected);
Connection connection = upgradeInfo.createConnection(servletWriter, noOpCloseListener);
new BeanWrapperImpl(webSocket).setPropertyValue("connection", connection);
new BeanWrapperImpl(servletWriter).setPropertyValue("connection", connection);
webSocketHelper.registerForReadEvent(webSocket);
}
代码示例来源:origin: eclipse-ee4j/tyrus
private void appendTraceHeaders(HttpServletResponse httpServletResponse, TyrusUpgradeResponse
tyrusUpgradeResponse) {
for (Map.Entry<String, List<String>> entry : tyrusUpgradeResponse.getHeaders().entrySet()) {
if (entry.getKey().contains(UpgradeResponse.TRACING_HEADER_PREFIX)) {
httpServletResponse.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
}
}
}
代码示例来源:origin: org.glassfish.tyrus/tyrus-core
/**
* Client side only - compose the {@link UpgradeRequest} and store it for further use.
*
* @return composed {@link UpgradeRequest}.
*/
public UpgradeRequest prepareRequest() {
Map<String, List<String>> requestHeaders = request.getHeaders();
updateHostAndOrigin(request);
requestHeaders.put(UpgradeRequest.CONNECTION, Collections.singletonList(UpgradeRequest.UPGRADE));
requestHeaders.put(UpgradeRequest.UPGRADE, Collections.singletonList(UpgradeRequest.WEBSOCKET));
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_KEY, Collections.singletonList(secKey.toString()));
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_VERSION, Collections.singletonList(VERSION));
if (!subProtocols.isEmpty()) {
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_PROTOCOL,
Collections.singletonList(Utils.getHeaderFromList(subProtocols, null)));
}
if (!extensions.isEmpty()) {
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_EXTENSIONS,
Collections.singletonList(
Utils.getHeaderFromList(extensions, new Utils.Stringifier<Extension>() {
@Override
String toString(Extension extension) {
return TyrusExtension.toString(extension);
}
}))
);
}
return request;
}
代码示例来源:origin: eclipse-ee4j/tyrus
/**
* Client side only - compose the {@link UpgradeRequest} and store it for further use.
*
* @return composed {@link UpgradeRequest}.
*/
public UpgradeRequest prepareRequest() {
Map<String, List<String>> requestHeaders = request.getHeaders();
updateHostAndOrigin(request);
requestHeaders.put(UpgradeRequest.CONNECTION, Collections.singletonList(UpgradeRequest.UPGRADE));
requestHeaders.put(UpgradeRequest.UPGRADE, Collections.singletonList(UpgradeRequest.WEBSOCKET));
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_KEY, Collections.singletonList(secKey.toString()));
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_VERSION, Collections.singletonList(VERSION));
if (!subProtocols.isEmpty()) {
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_PROTOCOL,
Collections.singletonList(Utils.getHeaderFromList(subProtocols, null)));
}
if (!extensions.isEmpty()) {
requestHeaders.put(HandshakeRequest.SEC_WEBSOCKET_EXTENSIONS,
Collections.singletonList(
Utils.getHeaderFromList(extensions, new Utils.Stringifier<Extension>() {
@Override
String toString(Extension extension) {
return TyrusExtension.toString(extension);
}
}))
);
}
return request;
}
代码示例来源:origin: org.springframework/spring-websocket
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
Writer servletWriter = newServletWriter(handler);
handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
response.flushBuffer();
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
Writer servletWriter = newServletWriter(handler);
handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
response.flushBuffer();
}
代码示例来源:origin: eclipse-ee4j/tyrus
private void writeTraceHeaders(FilterChainContext ctx, UpgradeResponse upgradeResponse) {
final HttpResponsePacket responsePacket =
((HttpRequestPacket) ((HttpContent) ctx.getMessage()).getHttpHeader()).getResponse();
for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
if (entry.getKey().contains(UpgradeResponse.TRACING_HEADER_PREFIX)) {
responsePacket.setHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
}
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
AsyncContext asyncContext = request.startAsync();
asyncContext.setTimeout(-1L);
Object nativeRequest = getNativeRequest(request);
BeanWrapper beanWrapper = new BeanWrapperImpl(nativeRequest);
Object httpSocket = beanWrapper.getPropertyValue("connection.connectionHandler.rawConnection");
Object webSocket = webSocketHelper.newInstance(request, httpSocket);
webSocketHelper.upgrade(webSocket, httpSocket, request.getServletContext());
response.flushBuffer();
boolean isProtected = request.getUserPrincipal() != null;
Writer servletWriter = servletWriterHelper.newInstance(webSocket, isProtected);
Connection connection = upgradeInfo.createConnection(servletWriter, noOpCloseListener);
new BeanWrapperImpl(webSocket).setPropertyValue("connection", connection);
new BeanWrapperImpl(servletWriter).setPropertyValue("connection", connection);
webSocketHelper.registerForReadEvent(webSocket);
}
代码示例来源:origin: org.springframework/spring-websocket
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
response.setStatus(upgradeResponse.getStatus());
upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
AsyncContext asyncContext = request.startAsync();
asyncContext.setTimeout(-1L);
Object nativeRequest = getNativeRequest(request);
BeanWrapper beanWrapper = new BeanWrapperImpl(nativeRequest);
Object httpSocket = beanWrapper.getPropertyValue("connection.connectionHandler.rawConnection");
Object webSocket = webSocketHelper.newInstance(request, httpSocket);
webSocketHelper.upgrade(webSocket, httpSocket, request.getServletContext());
response.flushBuffer();
boolean isProtected = request.getUserPrincipal() != null;
Writer servletWriter = servletWriterHelper.newInstance(webSocket, isProtected);
Connection connection = upgradeInfo.createConnection(servletWriter, noOpCloseListener);
new BeanWrapperImpl(webSocket).setPropertyValue("connection", connection);
new BeanWrapperImpl(servletWriter).setPropertyValue("connection", connection);
webSocketHelper.registerForReadEvent(webSocket);
}
代码示例来源:origin: eclipse-ee4j/tyrus
private void write(FilterChainContext ctx, UpgradeResponse response) {
final HttpResponsePacket responsePacket =
((HttpRequestPacket) ((HttpContent) ctx.getMessage()).getHttpHeader()).getResponse();
responsePacket.setProtocol(Protocol.HTTP_1_1);
responsePacket.setStatus(response.getStatus());
// TODO
// responsePacket.setReasonPhrase(response.getReasonPhrase());
for (Map.Entry<String, List<String>> entry : response.getHeaders().entrySet()) {
responsePacket.setHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
}
ctx.write(HttpContent.builder(responsePacket).build());
}
代码示例来源:origin: eclipse-ee4j/tyrus
httpServletResponse.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
代码示例来源:origin: eclipse-ee4j/tyrus
final List<String> locationHeader = upgradeResponse.getHeaders().get(UpgradeResponse.LOCATION);
if (locationHeader != null) {
locationString = Utils.getHeaderFromList(locationHeader);
代码示例来源:origin: org.glassfish.tyrus/tyrus-client
final List<String> locationHeader = upgradeResponse.getHeaders().get(UpgradeResponse.LOCATION);
if (locationHeader != null) {
locationString = Utils.getHeaderFromList(locationHeader);
代码示例来源:origin: org.glassfish.tyrus/tyrus-client
.get(UpgradeResponse.RETRY_AFTER);
if (retryAfterHeader != null) {
retryAfterString = Utils.getHeaderFromList(retryAfterHeader);
代码示例来源:origin: eclipse-ee4j/tyrus
.get(UpgradeResponse.RETRY_AFTER);
if (retryAfterHeader != null) {
retryAfterString = Utils.getHeaderFromList(retryAfterHeader);
代码示例来源:origin: eclipse-ee4j/tyrus
.WWW_AUTHENTICATE);
if (authHeader != null) {
wwwAuthenticateHeader = Utils.getHeaderFromList(authHeader);
代码示例来源:origin: org.glassfish.tyrus/tyrus-client
.WWW_AUTHENTICATE);
if (authHeader != null) {
wwwAuthenticateHeader = Utils.getHeaderFromList(authHeader);
内容来源于网络,如有侵权,请联系作者删除!