本文整理汇总了Java中io.netty.handler.codec.http.FullHttpRequest.headers方法的典型用法代码示例。如果您正苦于以下问题:Java FullHttpRequest.headers方法的具体用法?Java FullHttpRequest.headers怎么用?Java FullHttpRequest.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.FullHttpRequest
的用法示例。
在下文中一共展示了FullHttpRequest.headers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: debugRequestInfo
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
private void debugRequestInfo(HttpObject httpObject, String key) {
if (m_debugInfo && httpObject instanceof HttpRequest) {
if (key != null) {
LOGGER.debug("Cache Key: " + key);
}
if (httpObject instanceof FullHttpRequest) {
FullHttpRequest req = (FullHttpRequest) httpObject;
HttpHeaders headers = req.headers();
LOGGER.debug("Headers:");
for (Iterator<Entry<String, String>> it = headers.iterator(); it
.hasNext();) {
Entry<String, String> entry = it.next();
LOGGER.debug("\t" + entry.getKey() + ":\t"
+ entry.getValue());
}
ByteBuf content = req.content();
int length = content.readableBytes();
LOGGER.debug("Content Length: " + length);
if (length != 0) {
LOGGER.debug("Content: "
+ content.toString(Charset.forName("UTF-8")));
}
}
}
}
示例2: channelRead0
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req)throws Exception {
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, FOUND);
HttpHeaders headers = req.headers();
IConfig cfg = Config.getInstance();
StringBuilder sb = new StringBuilder();
if (cfg.isEncrypted()) {
sb.append(StringCache.HTTPS);
} else {
sb.append(StringCache.HTTP);
}
//finish up the url.
sb.append(headers.get(HttpHeaderNames.HOST)).append(StringCache.COLON).append(cfg.getPort()).append(req.uri());
//apply the redirect url
response.headers().set(HttpHeaderNames.LOCATION, sb.toString());
// Close the connection as soon as the redirect is sent.
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
示例3: decode
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
public static OneM2mRequest decode(FullHttpRequest request, String remoteHost) throws Exception {
Byte content[];
String method;
HashMap<String, String> headerMap = new HashMap<String, String>();
HttpHeaders headers = request.headers();
Iterator<Entry<String, String>> it = headers.iterator();
while (it.hasNext()) {
Entry<String, String> header = it.next();
headerMap.put(header.getKey().toUpperCase(), header.getValue());
}
if(request.content().isReadable()) {
return decode(request.getMethod().name(), request.getUri(), headerMap, remoteHost, request.content().copy().array());
} else {
return decode(request.getMethod().name(), request.getUri(), headerMap, remoteHost, null);
}
}
示例4: Netty4HttpRequest
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
Netty4HttpRequest(NamedXContentRegistry xContentRegistry, FullHttpRequest request, Channel channel) {
super(xContentRegistry, request.uri(), new HttpHeadersMap(request.headers()));
this.request = request;
this.channel = channel;
if (request.content().isReadable()) {
this.content = Netty4Utils.toBytesReference(request.content());
} else {
this.content = BytesArray.EMPTY;
}
}
示例5: getRequestHash
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
private String getRequestHash(FullHttpRequest request) {
HttpHeaders headers = request.headers();
String requestURI = getRequestURI(request);
HttpMethod requestMethod = request.getMethod();
Set<String> skipHeaders = m_skipHeaders;
boolean skipRequestContent = m_uriMatchEnabled
&& WildcardMatcher.isPatternCanBeMatchedIn(
m_uriMatchOnly,
new CacheDecisionObject(requestURI, requestMethod
.name()));
if(skipRequestContent){
skipHeaders = new HashSet<>(m_skipHeaders);
skipHeaders.add(HttpHeaders.Names.CONTENT_LENGTH.toUpperCase());
}
int uriHashcode = requestURI.hashCode();
int methodHashCode = requestMethod.hashCode();
List<Entry<String, String>> entries = headers.entries();
List<String> hashList = new ArrayList<>();
for (Iterator<Entry<String, String>> it = entries.iterator(); it
.hasNext();) {
Entry<String, String> entry = it.next();
if (skipHeaders.contains(entry.getKey().toUpperCase())) {
continue;
}
hashList.add(entry.getKey());
hashList.add(entry.getValue());
}
int headersHashcode = hashList.hashCode();
StringBuilder sb = new StringBuilder(4);
sb.append(uriHashcode).append(methodHashCode).append(headersHashcode);
if (!skipRequestContent) {
ByteBuf content = request.content();
sb.append(content.hashCode());
}
return Checksum.checksum(sb.toString());
}