Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/handler/ContextHandler.java @ 1013:6939226e0ac4
simplify URIUtil
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 24 Oct 2016 01:06:33 -0600 |
| parents | 32d4b569567c |
| children | 2b769da7f67d |
comparison
equal
deleted
inserted
replaced
| 1012:8d0bdd357e6e | 1013:6939226e0ac4 |
|---|---|
| 168 if (_contextPath.length() == target.length()) | 168 if (_contextPath.length() == target.length()) |
| 169 { | 169 { |
| 170 // context request must end with / | 170 // context request must end with / |
| 171 request.setHandled(true); | 171 request.setHandled(true); |
| 172 if (request.getQueryString() != null) | 172 if (request.getQueryString() != null) |
| 173 response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH) + "?" + request.getQueryString()); | 173 response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),"/") + "?" + request.getQueryString()); |
| 174 else | 174 else |
| 175 response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH)); | 175 response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),"/")); |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 return true; | 180 return true; |
| 201 target = target.substring(_contextPath.length()); | 201 target = target.substring(_contextPath.length()); |
| 202 pathInfo = target; | 202 pathInfo = target; |
| 203 } | 203 } |
| 204 else if (_contextPath.length() == 1) | 204 else if (_contextPath.length() == 1) |
| 205 { | 205 { |
| 206 target = URIUtil.SLASH; | 206 target = "/"; |
| 207 pathInfo = URIUtil.SLASH; | 207 pathInfo = "/"; |
| 208 } | 208 } |
| 209 else | 209 else |
| 210 { | 210 { |
| 211 target = URIUtil.SLASH; | 211 target = "/"; |
| 212 pathInfo = null; | 212 pathInfo = null; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 try | 216 try |
| 314 return b.toString(); | 314 return b.toString(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 public Resource getResource(String path) throws MalformedURLException | 317 public Resource getResource(String path) throws MalformedURLException |
| 318 { | 318 { |
| 319 if (path == null || !path.startsWith(URIUtil.SLASH)) | 319 if (path == null || !path.startsWith("/")) |
| 320 throw new MalformedURLException(path); | 320 throw new MalformedURLException(path); |
| 321 | 321 |
| 322 if (_baseResource == null) | 322 if (_baseResource == null) |
| 323 return null; | 323 return null; |
| 324 | 324 |
| 346 path = URIUtil.canonicalPath(path); | 346 path = URIUtil.canonicalPath(path); |
| 347 Resource resource = getResource(path); | 347 Resource resource = getResource(path); |
| 348 | 348 |
| 349 if (resource != null && resource.exists()) | 349 if (resource != null && resource.exists()) |
| 350 { | 350 { |
| 351 if (!path.endsWith(URIUtil.SLASH)) | 351 if (!path.endsWith("/")) |
| 352 path = path + URIUtil.SLASH; | 352 path = path + "/"; |
| 353 | 353 |
| 354 String[] l = resource.list(); | 354 String[] l = resource.list(); |
| 355 if (l != null) | 355 if (l != null) |
| 356 { | 356 { |
| 357 HashSet<String> set = new HashSet<String>(); | 357 HashSet<String> set = new HashSet<String>(); |
