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