本文整理匯總了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());
}