Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reenabled error message

  • Loading branch information...
commit 82a8c8c932042838d2c738e858af7abab90edd39 1 parent ee3784d
@pepite pepite authored
View
BIN  lib/netty-3.1.5.GA.jar
Binary file not shown
View
5 src/play/modules/netty/HttpServerPipelineFactory.java
@@ -15,13 +15,8 @@
public ChannelPipeline getPipeline() throws Exception {
Integer max = Integer.valueOf(Play.configuration.getProperty("play.module.netty.maxContentLength", "-1"));
-// if (max == -1) {
-// max = Integer.MAX_VALUE;
-// }
-
Integer threshold = Integer.valueOf(Play.configuration.getProperty("play.module.netty.threshold", "8192"));
-
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
View
48 src/play/modules/netty/PlayHandler.java
@@ -31,6 +31,7 @@
import java.io.*;
import java.net.URI;
+import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.ParseException;
import java.util.*;
@@ -153,7 +154,7 @@ public void run() {
public void execute() throws Exception {
Logger.trace("execute: begin");
ActionInvoker.invoke(request, response);
- //saveExceededSizeError(nettyRequest, response);
+ saveExceededSizeError(nettyRequest, response);
copyResponse(ctx, request, response, nettyRequest);
Logger.trace("execute: end");
}
@@ -180,7 +181,7 @@ void saveExceededSizeError(HttpRequest nettyRequest, Response response) {
throw new UnexpectedException("Flash serialization problem", e);
}
}
- } // Thread
+ }
protected static void addToResponse(Response response, HttpResponse nettyResponse) {
Map<String, Http.Header> headers = response.headers;
@@ -298,21 +299,21 @@ public static void copyResponse(ChannelHandlerContext ctx, Request request, Resp
Logger.trace("copyResponse: end");
}
- private static String escapeIllegalCharacters(String uri) throws Exception {
- // Encode uri according to RFC 2396
- return URLEncoder.encode(uri, "US-ASCII").replaceAll("%2F", "/").replaceAll("%3F", "?").replaceAll("%3D", "=").replaceAll("%26", "&");
- }
-
public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyRequest) throws Exception {
Logger.trace("parseRequest: begin");
- final URI uri = new URI(escapeIllegalCharacters(nettyRequest.getUri()));
+ int index = nettyRequest.getUri().indexOf("?");
+ String querystring = "";
+ String path = URLDecoder.decode(nettyRequest.getUri(), "UTF-8");
+ if (index != -1) {
+ path = URLDecoder.decode(nettyRequest.getUri().substring(0, index), "UTF-8");
+ querystring = nettyRequest.getUri().substring(index + 1);
+ }
final Request request = new Request();
request.remoteAddress = ctx.getChannel().getRemoteAddress().toString();
request.method = nettyRequest.getMethod().getName();
- request.path = uri.getPath();
- request.querystring = uri.getQuery() == null ? "" : uri.getQuery();
-
+ request.path = path;
+ request.querystring = querystring;
final String contentType = nettyRequest.getHeader(CONTENT_TYPE);
if (contentType != null) {
request.contentType = contentType.split(";")[0].trim().toLowerCase();
@@ -335,7 +336,7 @@ public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyR
request.body = new ChannelBufferInputStream(b);
}
- request.url = uri.toASCIIString();
+ request.url = nettyRequest.getUri();
request.host = nettyRequest.getHeader(HOST);
if (request.host.contains(":")) {
@@ -406,7 +407,7 @@ protected static void addToRequest(HttpRequest nettyRequest, Request request) {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
- e.getCause().printStackTrace();
+ //e.getCause().printStackTrace();
e.getChannel().close();
}
@@ -591,25 +592,8 @@ public static void serveStatic(RenderStatic renderStatic, ChannelHandlerContext
ch.write(nettyResponse);
// Write the content.
- ChannelFuture writeFuture;
-
- writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
-//
-// // No encryption - use zero-copy.
-// final FileRegion region =
-// new DefaultFileRegion(raf.getChannel(), 0, fileLength);
-// writeFuture = ch.write(region);
-// writeFuture.addListener(new ChannelFutureProgressListener() {
-// public void operationComplete(ChannelFuture future) {
-// region.releaseExternalResources();
-// }
-//
-// public void operationProgressed(
-// ChannelFuture future, long amount, long current, long total) {
-// System.out.printf("%s: %d / %d (+%d)%n", localFile.getPath(), current, total, amount);
-//
-// }
-// });
+ ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
+
if (!isKeepAlive(nettyRequest)) {
// Close the connection when the whole content is written out.
writeFuture.addListener(ChannelFutureListener.CLOSE);
Please sign in to comment.
Something went wrong with that request. Please try again.