Skip to content

Commit

Permalink
Revert "[#302]"
Browse files Browse the repository at this point in the history
This reverts commit 9744993.
  • Loading branch information
pepite committed Oct 17, 2010
1 parent 9744993 commit db48942
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
16 changes: 7 additions & 9 deletions framework/src/play/mvc/Router.java
Expand Up @@ -323,7 +323,7 @@ public static String reverse(VirtualFile file, boolean absolute) {
}
if (absolute) {
if (!StringUtils.isEmpty(route.host)) {
to = (Http.Request.current().secure ? "https://" : "http://") + route.host + to;
to = "http://" + route.host + to;
} else {
to = Http.Request.current().getBase() + to;
}
Expand Down Expand Up @@ -502,12 +502,10 @@ public String toString() {
}

public void absolute() {
if (!url.startsWith("http")) {
if (StringUtils.isEmpty(host)) {
url = Http.Request.current().getBase() + url;
} else {
url = (Http.Request.current().secure ? "https://" : "http://") + host + url;
}
if (StringUtils.isEmpty(host)) {
url = Http.Request.current().getBase() + url;
} else {
url = "http://" + host + url;
}
}

Expand Down Expand Up @@ -573,7 +571,7 @@ public void compute() {
String p = this.path;
this.path = p.substring(p.indexOf("/"));
this.host = p.substring(0, p.indexOf("/"));
String pattern = host.replaceAll("\\.", "\\\\.").replaceFirst("\\{.*\\}", "(.*)");
String pattern = host.replaceAll("\\.","\\\\.").replaceFirst("\\{.*\\}", "(.*)");
Logger.trace("pattern [" + pattern + "]");
Logger.trace("host [" + host + "]");

Expand All @@ -582,7 +580,7 @@ public void compute() {

if (m.matches()) {
if (this.host.contains("{")) {
String name = m.group(1).replace("{", "").replace("}", "");
String name = m.group(1).replace("{", "").replace("}","");
hostArg = new Arg();
hostArg.name = name;
Logger.trace("hostArg name [" + name + "]");
Expand Down
13 changes: 2 additions & 11 deletions framework/src/play/server/PlayHandler.java
Expand Up @@ -49,10 +49,6 @@ public class PlayHandler extends SimpleChannelUpstreamHandler {

private final static String signature = "Play! Framework;" + Play.version + ";" + Play.mode.name().toLowerCase();

public Request processRequest(Request request) {
return request;
}

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
Logger.trace("messageReceived: begin");
Expand All @@ -61,8 +57,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Ex
if (msg instanceof HttpRequest) {
final HttpRequest nettyRequest = (HttpRequest) msg;
try {
Request request = parseRequest(ctx, nettyRequest);
request = processRequest(request);
final Request request = parseRequest(ctx, nettyRequest);
final Response response = new Response();

Http.Response.current.set(response);
Expand All @@ -86,7 +81,6 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Ex
}
Logger.trace("messageReceived: end");
}

private static Map<String, RenderStatic> staticPathsCache = new HashMap<String, RenderStatic>();

public class NettyInvocation extends Invoker.Invocation {
Expand Down Expand Up @@ -373,7 +367,6 @@ static String getRemoteIPAddress(ChannelHandlerContext ctx) {
return fullAddress;
}


public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyRequest) throws Exception {
Logger.trace("parseRequest: begin");
Logger.trace("parseRequest: URI = " + nettyRequest.getUri());
Expand All @@ -385,11 +378,10 @@ public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyR
querystring = nettyRequest.getUri().substring(index + 1);
}

final Http.Request request = new Http.Request();
final Request request = new Request();

request.remoteAddress = getRemoteIPAddress(ctx);
request.method = nettyRequest.getMethod().getName();

request.path = path;
request.querystring = querystring;
final String contentType = nettyRequest.getHeader(CONTENT_TYPE);
Expand Down Expand Up @@ -496,7 +488,6 @@ protected static void addToRequest(HttpRequest nettyRequest, Request request) {
}
}


@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
Expand Down
7 changes: 0 additions & 7 deletions framework/src/play/server/ssl/SslPlayHandler.java
Expand Up @@ -4,7 +4,6 @@
import org.jboss.netty.handler.codec.http.*;
import org.jboss.netty.handler.ssl.SslHandler;
import play.Logger;
import play.mvc.Http;
import play.server.PlayHandler;
import play.server.Server;

Expand Down Expand Up @@ -43,12 +42,6 @@ public void operationComplete(ChannelFuture future) throws Exception {

}

@Override
public Http.Request processRequest(Http.Request request) {
request.secure = true;
return request;
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
Expand Down

0 comments on commit db48942

Please sign in to comment.