/** * Returns the resource contained inside the current resource with the * given name */ @Override public Resource addPath(String path) throws IOException,MalformedURLException { if (path==null) return null; path = URIUtil.canonicalPath(path); return newResource(URIUtil.addEncodedPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches); }
public FileResource(File base, String childPath) { String encoded = URIUtil.encodePath(childPath); _file = new File(base, childPath); // The encoded path should be a suffix of the resource (give or take a directory / ) URI uri; try { if (base.isDirectory()) { // treat all paths being added as relative uri=new URI(URIUtil.addEncodedPaths(base.toURI().toASCIIString(),encoded)); } else { uri=new URI(base.toURI().toASCIIString()+encoded); } } catch (final URISyntaxException e) { throw new InvalidPathException(base.toString() + childPath, e.getMessage()) { { initCause(e); } }; } _uri=uri; _alias=checkFileAlias(_uri,_file); }
buf.append(URIUtil.addEncodedPaths(base,"../")); buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n"); String path=URIUtil.addEncodedPaths(encodedBase,URIUtil.encodePath(ls[i]));
protected void sendDirectory(HttpServletRequest request, HttpServletResponse response, Resource resource, String pathInContext) throws IOException { if (!_dirAllowed) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } byte[] data=null; String base = URIUtil.addEncodedPaths(request.getRequestURI(),URIUtil.SLASH); String dir = resource.getListHTML(base,pathInContext.length()>1); if (dir==null) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "No directory"); return; } data=dir.getBytes("utf-8"); response.setContentType("text/html;charset=utf-8"); response.setContentLength(data.length); response.getOutputStream().write(data); }
public FileResource(File base, String childPath) { String encoded = URIUtil.encodePath(childPath); _file = new File(base, childPath); // The encoded path should be a suffix of the resource (give or take a directory / ) URI uri; try { if (base.isDirectory()) { // treat all paths being added as relative uri=new URI(URIUtil.addEncodedPaths(base.toURI().toASCIIString(),encoded)); } else { uri=new URI(base.toURI().toASCIIString()+encoded); } } catch (final URISyntaxException e) { throw new InvalidPathException(base.toString() + childPath, e.getMessage()) { { initCause(e); } }; } _uri=uri; _alias=checkFileAlias(_uri,_file); }
/** * Returns the resource contained inside the current resource with the * given name */ @Override public Resource addPath(String path) throws IOException,MalformedURLException { if (path==null) return null; path = URIUtil.canonicalPath(path); return newResource(URIUtil.addEncodedPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches); }
location = URIUtil.canonicalPath(URIUtil.addEncodedPaths(parent,location)); if (!location.startsWith("/")) url.append('/');
buf.append(URIUtil.addEncodedPaths(base,"../")); buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n"); String path=URIUtil.addEncodedPaths(encodedBase,URIUtil.encodePath(ls[i]));
location=URIUtil.canonicalEncodedPath(URIUtil.addEncodedPaths(parent,location)); if (location!=null && !location.startsWith("/")) buf.append('/');
public void handleAsync(HttpChannel channel) throws IOException, ServletException { final HttpChannelState state = channel.getRequest().getHttpChannelState(); final AsyncContextEvent event = state.getAsyncContextEvent(); final Request baseRequest=channel.getRequest(); final String path=event.getPath(); if (path!=null) { // this is a dispatch with a path ServletContext context=event.getServletContext(); String query=baseRequest.getQueryString(); baseRequest.setURIPathQuery(URIUtil.addEncodedPaths(context==null?null:URIUtil.encodePath(context.getContextPath()), path)); HttpURI uri = baseRequest.getHttpURI(); baseRequest.setPathInfo(uri.getDecodedPath()); if (uri.getQuery()!=null) baseRequest.mergeQueryParameters(query,uri.getQuery(), true); //we have to assume dispatch path and query are UTF8 } final String target=baseRequest.getPathInfo(); final HttpServletRequest request=(HttpServletRequest)event.getSuppliedRequest(); final HttpServletResponse response=(HttpServletResponse)event.getSuppliedResponse(); if (LOG.isDebugEnabled()) LOG.debug("{} {} {} on {}", request.getDispatcherType(), request.getMethod(), target, channel); handle(target, baseRequest, request, response); if (LOG.isDebugEnabled()) LOG.debug("handledAsync={} async={} committed={} on {}", channel.getRequest().isHandled(),request.isAsyncStarted(),response.isCommitted(),channel); }