当前位置: 首页>>代码示例>>Java>>正文


Java FullHttpRequest.headers方法代码示例

本文整理汇总了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")));
			}
		}
	}
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:26,代码来源:NettyRequestProxyFilter.java

示例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);
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:26,代码来源:RedirectionHandler.java

示例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);				
	}
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:19,代码来源:HttpRequestCodec.java

示例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;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Netty4HttpRequest.java

示例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());
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:42,代码来源:RequestKeyGenerator.java


注:本文中的io.netty.handler.codec.http.FullHttpRequest.headers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。