Permalink
Browse files

Fixed an off-by-one error in calculating if the last element of a req…

…uest was a /
  • Loading branch information...
1 parent 1cc2a43 commit b1ed911ea9aa965c6de292226dce7670a37a2576 @dpp dpp committed Sep 23, 2011
@@ -338,7 +338,16 @@ object FileParamHolder {
}
}
-private[http] object CurrentReq extends ThreadGlobal[Req]
+/**
+ * A Thread-global containing the current Req. Set very, very early
+ */
+object CurrentReq extends ThreadGlobal[Req]
+
+/**
+ * A ThreadGlobal containing the low-level HTTPRequest and HTTPResponse instances
+ * Set very, very early.
+ */
+object CurrentHTTPReqResp extends ThreadGlobal[(HTTPRequest, HTTPResponse)]
private final case class AvoidGAL(func: () => ParamCalcInfo) {
lazy val thunk: ParamCalcInfo = func()
@@ -520,7 +529,7 @@ object Req {
def parsePath(in: String): ParsePath = {
val p1 = fixURI((in match {case null => "/"; case s if s.length == 0 => "/"; case s => s}).replaceAll("/+", "/"))
val front = p1.startsWith("/")
- val back = p1.length > 1 && p1.endsWith("/")
+ val back = p1.length >= 1 && p1.endsWith("/")
val orgLst = p1.replaceAll("/$", "/index").split("/").
toList.map(_.trim).filter(_.length > 0)
@@ -57,21 +57,23 @@ trait HTTPProvider {
LiftRules.early.toList.foreach(_(req))
}
- val newReq = Req(req, LiftRules.statelessRewrite.toList,
- LiftRules.statelessTest.toList,
- LiftRules.statelessReqTest.toList,
- System.nanoTime)
-
- CurrentReq.doWith(newReq) {
- URLRewriter.doWith(url =>
- NamedPF.applyBox(resp.encodeUrl(url),
- LiftRules.urlDecorate.toList) openOr
- resp.encodeUrl(url)) {
- if (!(isLiftRequest_?(newReq) &&
- actualServlet.service(newReq, resp))) {
- chain
- }
- }
+ CurrentHTTPReqResp.doWith(req -> resp) {
+ val newReq = Req(req, LiftRules.statelessRewrite.toList,
+ LiftRules.statelessTest.toList,
+ LiftRules.statelessReqTest.toList,
+ System.nanoTime)
+
+ CurrentReq.doWith(newReq) {
+ URLRewriter.doWith(url =>
+ NamedPF.applyBox(resp.encodeUrl(url),
+ LiftRules.urlDecorate.toList) openOr
+ resp.encodeUrl(url)) {
+ if (!(isLiftRequest_?(newReq) &&
+ actualServlet.service(newReq, resp))) {
+ chain
+ }
+ }
+ }
}
}

0 comments on commit b1ed911

Please sign in to comment.