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


Java HttpResponse.getHeaders方法代码示例

本文整理汇总了Java中org.jboss.netty.handler.codec.http.HttpResponse.getHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.getHeaders方法的具体用法?Java HttpResponse.getHeaders怎么用?Java HttpResponse.getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.handler.codec.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.getHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import org.jboss.netty.handler.codec.http.HttpResponse; //导入方法依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg)
        throws Exception
{
  HttpResponse nettyResponse = (HttpResponse) msg;

  RestResponseBuilder builder = new RestResponseBuilder();

  HttpResponseStatus status = nettyResponse.getStatus();
  builder.setStatus(status.getCode());

  for (Map.Entry<String, String> e : nettyResponse.getHeaders())
  {
    builder.unsafeAddHeaderValue(e.getKey(), e.getValue());
  }

  ChannelBuffer buf = nettyResponse.getContent();
  byte[] array = new byte[buf.readableBytes()];
  buf.readBytes(array);
  builder.setEntity(array);

  return builder.build();
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:24,代码来源:RAPClientCodec.java

示例2: invokeForFile

import org.jboss.netty.handler.codec.http.HttpResponse; //导入方法依赖的package包/类
/**
	 * Handles a prepared WebSocket API invocation to retrieve a static file
	 * @param request The prepared HTTP request so we can piggy-back on the existing RpcHandler services.
	 * @param response The JSONResponse to write back to
	 * @throws IOException thrown on IO errors
	 */
	protected void invokeForFile(HttpRequest request, JSONResponse response) throws IOException {
		JsonGenerator generator = response.writeHeader(true);		
		InvocationChannel ichannel = new InvocationChannel();		
		HttpQuery query = new HttpQuery(tsdb, request, ichannel);
		String baseRoute = query.getQueryBaseRoute();
//		http_commands.get(baseRoute).execute(tsdb, query);
		HttpResponse resp = (HttpResponse)ichannel.getWrites().get(0);
		byte[] regionBytes = (byte[])ichannel.getWrites().get(1);
		
		List<Map.Entry<String, String>> responseHeaders = resp.getHeaders();
		for(Map.Entry<String, String> entry: responseHeaders) {
			generator.writeStringField(entry.getKey(), entry.getValue());
			//log.info("Reponse Header: [{}] : [{}]", entry.getKey(), entry.getValue());
		}
		
		String cType = resp.getHeader("Content-Type");
		if(cType!=null) {
			if(cType.startsWith("text")) {
				generator.writeStringField("content", new String(regionBytes));
			} else {
				ChannelBuffer b64 = Base64.encode(ChannelBuffers.wrappedBuffer(regionBytes));
				byte[] bytes = new byte[b64.readableBytes()];
				b64.readBytes(bytes);
				generator.writeBinaryField("content", bytes);
			}
		}
		
		response.closeGenerator();
	}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:36,代码来源:TSDBJSONService.java

示例3: writeRequested

import org.jboss.netty.handler.codec.http.HttpResponse; //导入方法依赖的package包/类
@Override
public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent evt)
	throws Exception
{
	final HttpResponse resp = (HttpResponse)evt.getMessage();
	LogManager.i("====================writeRequested : "+resp.toString());

	final Level level = Level.FINE;
	if (Constants.DEBUG) {
		final StringBuilder s = new StringBuilder();
		s.append("<");
		s.append(resp.getStatus().getCode());
		s.append(" ");
		s.append(resp.getStatus().getReasonPhrase());
		s.append("\n");
		for(final Map.Entry<String, String> header: resp.getHeaders()) {
			s.append("  ");
			s.append(header.getKey());
			s.append(": ");
			s.append(header.getValue());
			s.append("\n");
		}
		LogManager.i("writeRequested: "+ s.toString());
	}

	super.writeRequested(ctx, evt);
}
 
开发者ID:lukeqsun,项目名称:AirSpeakerMobile,代码行数:28,代码来源:RtspLoggingHandler.java

示例4: dump

import org.jboss.netty.handler.codec.http.HttpResponse; //导入方法依赖的package包/类
private void dump(HttpResponse response) {
    if (!this.logger.isDebugEnabled()) {
        return;
    }
    this.logger.debug("%s|%s", response.getStatus().getCode(),
            response.getStatus().getReasonPhrase());
    for (Entry<String, String> h : response.getHeaders()) {
        this.logger.debug("%s=%s", h.getKey(), h.getValue());
    }
}
 
开发者ID:kuiwang,项目名称:my-dev,代码行数:11,代码来源:WebSocketClientUpstreamHandler.java


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