本文整理了Java中org.glassfish.tyrus.core.Utils.parseHeaderValue()
方法的一些代码示例,展示了Utils.parseHeaderValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.parseHeaderValue()
方法的具体详情如下:
包路径:org.glassfish.tyrus.core.Utils
类名称:Utils
方法名:parseHeaderValue
[英]Parse header value - splits multiple values (quoted, unquoted) separated by comma.
[中]解析标题值-拆分多个值(带引号、不带引号),用逗号分隔。
代码示例来源:origin: eclipse-ee4j/tyrus
TyrusUpgradeResponse parseUpgradeResponse() throws ParseException {
String response = bufferToString();
String[] tokens = response.split(LINE_SEPARATOR);
TyrusUpgradeResponse tyrusUpgradeResponse = new TyrusUpgradeResponse();
parseFirstLine(tokens, tyrusUpgradeResponse);
List<String> lines = new LinkedList<>();
lines.addAll(Arrays.asList(tokens).subList(1, tokens.length));
Map<String, String> headers = parseHeaders(lines);
for (Map.Entry<String, String> entry : headers.entrySet()) {
final List<String> values = tyrusUpgradeResponse.getHeaders().get(entry.getKey());
if (values == null) {
tyrusUpgradeResponse.getHeaders().put(entry.getKey(), Utils.parseHeaderValue(entry.getValue()));
} else {
values.addAll(Utils.parseHeaderValue(entry.getValue()));
}
}
return tyrusUpgradeResponse;
}
代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly-client
private static UpgradeResponse getUpgradeResponse(HttpResponsePacket httpResponsePacket) {
TyrusUpgradeResponse tyrusUpgradeResponse = new TyrusUpgradeResponse();
for (String name : httpResponsePacket.getHeaders().names()) {
for (String headerValue : httpResponsePacket.getHeaders().values(name)) {
final List<String> values = tyrusUpgradeResponse.getHeaders().get(name);
if (values == null) {
tyrusUpgradeResponse.getHeaders().put(name, Utils.parseHeaderValue(headerValue.trim()));
} else {
values.addAll(Utils.parseHeaderValue(headerValue.trim()));
}
}
}
tyrusUpgradeResponse.setStatus(httpResponsePacket.getStatus());
return tyrusUpgradeResponse;
}
代码示例来源:origin: eclipse-ee4j/tyrus
private static UpgradeResponse getUpgradeResponse(HttpResponsePacket httpResponsePacket) {
TyrusUpgradeResponse tyrusUpgradeResponse = new TyrusUpgradeResponse();
for (String name : httpResponsePacket.getHeaders().names()) {
for (String headerValue : httpResponsePacket.getHeaders().values(name)) {
final List<String> values = tyrusUpgradeResponse.getHeaders().get(name);
if (values == null) {
tyrusUpgradeResponse.getHeaders().put(name, Utils.parseHeaderValue(headerValue.trim()));
} else {
values.addAll(Utils.parseHeaderValue(headerValue.trim()));
}
}
}
tyrusUpgradeResponse.setStatus(httpResponsePacket.getStatus());
return tyrusUpgradeResponse;
}
代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly
private static WebSocketRequest createWebSocketRequest(final FilterChainContext ctx, final HttpContent requestContent) {
final HttpRequestPacket requestPacket = (HttpRequestPacket) requestContent.getHttpHeader();
final RequestContext requestContext = RequestContext.Builder.create()
.requestURI(URI.create(requestPacket.getRequestURI()))
.queryString(requestPacket.getQueryString())
.connection(getWebSocketConnection(ctx, requestContent))
.secure(requestPacket.isSecure())
.build();
for (String name : requestPacket.getHeaders().names()) {
final List<String> values = requestContext.getHeaders().get(name);
if(values == null) {
requestContext.getHeaders().put(name, Utils.parseHeaderValue(requestPacket.getHeader(name).trim()));
} else {
values.addAll(Utils.parseHeaderValue(requestPacket.getHeader(name).trim()));
}
}
return requestContext;
}
}
代码示例来源:origin: eclipse-ee4j/tyrus
requestContext.getHeaders().put(name, Utils.parseHeaderValue(
headerValues.nextElement().trim()));
} else {
values.addAll(Utils.parseHeaderValue(headerValues.nextElement().trim()));
代码示例来源:origin: eclipse-ee4j/tyrus
private static UpgradeRequest createWebSocketRequest(final HttpContent requestContent) {
final HttpRequestPacket requestPacket = (HttpRequestPacket) requestContent.getHttpHeader();
Parameters parameters = new Parameters();
parameters.setQuery(requestPacket.getQueryStringDC());
parameters.setQueryStringEncoding(Charsets.UTF8_CHARSET);
Map<String, String[]> parameterMap = new HashMap<String, String[]>();
for (String paramName : parameters.getParameterNames()) {
parameterMap.put(paramName, parameters.getParameterValues(paramName));
}
final RequestContext requestContext = RequestContext.Builder.create()
.requestURI(
URI.create(requestPacket.getRequestURI()))
.queryString(requestPacket.getQueryString())
.parameterMap(parameterMap)
.secure(requestPacket.isSecure())
.remoteAddr(requestPacket.getRemoteAddress())
.build();
for (String name : requestPacket.getHeaders().names()) {
for (String headerValue : requestPacket.getHeaders().values(name)) {
final List<String> values = requestContext.getHeaders().get(name);
if (values == null) {
requestContext.getHeaders().put(name, Utils.parseHeaderValue(headerValue.trim()));
} else {
values.addAll(Utils.parseHeaderValue(headerValue.trim()));
}
}
}
return requestContext;
}
内容来源于网络,如有侵权,请联系作者删除!