當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpRequest.isChunked方法代碼示例

本文整理匯總了Java中org.jboss.netty.handler.codec.http.HttpRequest.isChunked方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequest.isChunked方法的具體用法?Java HttpRequest.isChunked怎麽用?Java HttpRequest.isChunked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.handler.codec.http.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.isChunked方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: messageReceived

import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    if (!readingChunks) {
        request = (HttpRequest) e.getMessage();
        String uri = request.getUri();
        if (uri.equals("/exception")) {
            throw new Exception("Test");
        }
        if (request.isChunked()) {
            readingChunks = true;
        } else {
            writeResponse(e);
        }
    } else {
        HttpChunk chunk = (HttpChunk) e.getMessage();
        if (chunk.isLast()) {
            readingChunks = false;
            writeResponse(e);
        }
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:22,代碼來源:HttpServerHandler.java

示例2: messageReceived

import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void messageReceived(ChannelHandlerContext context, MessageEvent messageEvent) throws Exception {
	if (!readingChunks) {
		HttpRequest httpRequest = (HttpRequest) messageEvent.getMessage();

		request = Request.create(httpRequest, messageEvent);
		response = new Response();

		content.setLength(0);
		content.append(httpRequest.getContent().toString(Context.DEFAULT_CHARSET));

		if (httpRequest.isChunked()) {
			readingChunks = true;
		} else {
			ready = true;
		}
	} else {
		HttpChunk httpChunk = (HttpChunk) messageEvent.getMessage();
		content.append(httpChunk.getContent().toString(Context.DEFAULT_CHARSET));

		if (httpChunk.isLast()) {
			ready = true;
			readingChunks = false;
		}
	}

	if (ready) {
		ready = false;
		handleMessage(context, messageEvent);
	}
}
 
開發者ID:iceize,項目名稱:netty-http-3.x,代碼行數:32,代碼來源:RemoteRequestHandler.java

示例3: dispatchRequest

import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
private void dispatchRequest(ChannelHandlerContext ctx,
		HttpRequest nettyRequest) {
	if(nettyRequest.isChunked()) {
		server.getExecutor().submit(new RequestWorker(ctx, nettyRequest));
	} else {
		new RequestWorker(ctx, nettyRequest).run();
	}
}
 
開發者ID:ludup,項目名稱:hypersocket-framework,代碼行數:9,代碼來源:HttpRequestDispatcherHandler.java

示例4: RequestWorker

import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
RequestWorker(ChannelHandlerContext ctx,
	HttpRequest nettyRequest) {
	this.ctx = ctx;
	this.nettyRequest = nettyRequest;
	
	interfaceResource = (HTTPInterfaceResource) ctx.getChannel().getParent().getAttachment();
	
	nettyResponse = new HttpResponseServletWrapper(
			new DefaultHttpResponse(HttpVersion.HTTP_1_1,
					HttpResponseStatus.OK),
			ctx.getChannel(), nettyRequest);
	
	session = server.setupHttpSession(
			nettyRequest.getHeaders("Cookie"), 
			interfaceResource.getProtocol()==HTTPProtocol.HTTPS,
			nettyResponse);
	
	InetSocketAddress remoteAddress = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
	if(nettyRequest.containsHeader("X-Forwarded-For")) {
		String[] ips = nettyRequest.getHeader("X-Forwarded-For").split(",");
		remoteAddress = new InetSocketAddress(ips[0], remoteAddress.getPort());
	} else if(nettyRequest.containsHeader("Forwarded")) {
		StringTokenizer t = new StringTokenizer(nettyRequest.getHeader("Forwarded"), ";");
		while(t.hasMoreTokens()) {
			String[] pair = t.nextToken().split("=");
			if(pair.length == 2 && pair[0].equalsIgnoreCase("for")) {
				remoteAddress = new InetSocketAddress(pair[1], remoteAddress.getPort());
			}
		}
	}
	
	servletRequest = new HttpRequestServletWrapper(
			nettyRequest, (InetSocketAddress) ctx.getChannel()
					.getLocalAddress(), remoteAddress, 
					interfaceResource.getProtocol()==HTTPProtocol.HTTPS, 
					server.getServletConfig().getServletContext(), session);
	
	if(nettyRequest.isChunked()) {
		ctx.getChannel().setAttachment(servletRequest);
	}
}
 
開發者ID:ludup,項目名稱:hypersocket-framework,代碼行數:42,代碼來源:HttpRequestDispatcherHandler.java


注:本文中的org.jboss.netty.handler.codec.http.HttpRequest.isChunked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。