當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。