congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
URIUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
URIUtil
in
org.eclipse.jetty.util

Best Java code snippets using org.eclipse.jetty.util.URIUtil (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Logger
  • HttpServletRequest
  • Request
  • HttpServletResponse
  • Resource
  • ContextHandler
origin: org.eclipse.jetty/jetty-security

Request base_request = Request.getBaseRequest(request);
Response base_response = base_request.getResponse();
String uri = request.getRequestURI();
if (uri==null)
  uri=URIUtil.SLASH;
  return new DeferredAuthentication(this);
if (isLoginOrErrorPage(URIUtil.addPaths(request.getServletPath(),request.getPathInfo())) &&!DeferredAuthentication.isDeferred(response))
  return new DeferredAuthentication(this);
    LOG.debug("jsecuritycheck {} {}",username,user);
    HttpSession session = request.getSession(false);
    if (user!=null)
      LOG.debug("authenticated {}->{}",form_auth,nuri);
      LOG.debug("auth failed {}->{}",username,_formErrorPage);
      int redirectCode = (base_request.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
      base_response.sendRedirect(redirectCode, response.encodeRedirectURL(URIUtil.addPaths(request.getContextPath(),_formErrorPage)));
    LOG.debug("challenge {}->{}",session.getId(),_formLoginPage);
    int redirectCode = (base_request.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
    base_response.sendRedirect(redirectCode, response.encodeRedirectURL(URIUtil.addPaths(request.getContextPath(),_formLoginPage)));
origin: org.eclipse.jetty/jetty-webapp

String tmp = URIUtil.decodePath(resource.getURL().getPath());
if (tmp.endsWith("/"))
  tmp = tmp.substring(0, tmp.length()-1);
LOG.warn("Can't generate resourceBase as part of webapp tmp dir name: " + e);
LOG.debug(e);
origin: org.eclipse.jetty/jetty-util

if (!URIUtil.equalsIgnoreEncodings(uri,file.toURI()))
  if (LOG.isDebugEnabled())
    LOG.debug("ALIAS abs={} can={}",abs,can);
  return new URI("file://"+URIUtil.encodePath(alias.getPath()));
LOG.warn("bad alias for {}: {}",file,e.toString());
LOG.debug(e);
try
origin: org.eclipse.jetty/jetty-util

/**
 * 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);
}
origin: org.eclipse.jetty/jetty-util

throws IOException
base=URIUtil.canonicalPath(base);
if (base==null || !isDirectory())
  return null;
String[] ls = list();
if (ls==null)
  return null;
Arrays.sort(ls);
String decodedBase = URIUtil.decodePath(base);
String title = "Directory: "+deTag(decodedBase);
  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]));
origin: org.eclipse.jetty.aggregate/jetty-all-server

public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
  if (_newContextURL==null)
    return;
  String path=_newContextURL;
  if (!_discardPathInfo && request.getPathInfo()!=null)
    path=URIUtil.addPaths(path, request.getPathInfo());
  
  StringBuilder location = URIUtil.hasScheme(path)?new StringBuilder():baseRequest.getRootURL();
  location.append(path);
  if (!_discardQuery && request.getQueryString()!=null)
  {
    location.append('?');
    String q=request.getQueryString();
    q=q.replaceAll("\r\n?&=","!");
    location.append(q);
  }
  
  response.setHeader(HttpHeaders.LOCATION,location.toString());
  if (_expires!=null)
    response.setHeader(HttpHeaders.EXPIRES,_expires);
  
  response.setStatus(_permanent?HttpServletResponse.SC_MOVED_PERMANENTLY:HttpServletResponse.SC_FOUND);
  response.setContentLength(0);
  baseRequest.setHandled(true);
}

origin: i2p/i2p.i2p

  response.sendError(HttpServletResponse.SC_FORBIDDEN);
  return;
String base = URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH);
    resource=_resourceBase.addPath(pathInContext);
else if (_contextHandler.getBaseResource() instanceof ResourceCollection)
  resource=_contextHandler.getBaseResource().addPath(pathInContext);
  response.sendError(HttpServletResponse.SC_FORBIDDEN,
  "No directory");
  return;
response.setContentType("text/html; charset=UTF-8");
response.setContentLength(data.length);
response.getOutputStream().write(data);
origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.servlet

protected void notFound(Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
  if (LOG.isDebugEnabled())
    LOG.debug("Not Found {}",request.getRequestURI());
  if (getHandler()!=null)
    nextHandle(URIUtil.addPaths(request.getServletPath(),request.getPathInfo()),baseRequest,request,response);
}
origin: org.eclipse.jetty.aggregate/jetty-all-server

protected void startAsync(final ServletContext context,
    final ServletRequest request,
    final ServletResponse response)
{
  synchronized (this)
  {
    _responseWrapped=!(response instanceof Response);
    doSuspend(context,request,response);
    if (request instanceof HttpServletRequest)
    {
      _event._pathInContext = URIUtil.addPaths(((HttpServletRequest)request).getServletPath(),((HttpServletRequest)request).getPathInfo());
    }
  }
}
origin: org.eclipse.jetty/jetty-rewrite

if (!URIUtil.hasScheme(location))
  URIUtil.appendSchemeHostPort(url,request.getScheme(),request.getServerName(),request.getServerPort());
    location = URIUtil.canonicalEncodedPath(location);
    String path = request.getRequestURI();
    String parent = (path.endsWith("/")) ? path : URIUtil.parentPath(path);
    location = URIUtil.canonicalPath(URIUtil.addEncodedPaths(parent,location));
    if (!location.startsWith("/"))
      url.append('/');
origin: org.eclipse.jetty.aggregate/jetty-all-server

  if (LOG.isDebugEnabled())
    LOG.debug("call filter " + _filterHolder);
  Filter filter= _filterHolder.getFilter();
  if (_filterHolder.isAsyncSupported())
  else
    final boolean suspendable=baseRequest.isAsyncSupported();
    if (suspendable)
        baseRequest.setAsyncSupported(false);
        filter.doFilter(request, response, _next);
        baseRequest.setAsyncSupported(true);
if (_servletHolder != null)
  if (LOG.isDebugEnabled())
    LOG.debug("call servlet " + _servletHolder);
  _servletHolder.handle(baseRequest,request, response);
  notFound(srequest, (HttpServletResponse)response);
else
  nextHandle(URIUtil.addPaths(srequest.getServletPath(),srequest.getPathInfo()),
        baseRequest,srequest,(HttpServletResponse)response);
origin: fabric8io/jube

  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // only redirect if its / to hawtio
    if (req.getRequestURI().equals("/")) {
      String url = URIUtil.addPaths(req.getRequestURI(), "hawtio");
      resp.sendRedirect(url);
    }
  }
}
origin: jenkinsci/winstone

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);
}
origin: jenkinsci/winstone

@Override
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException
{
  if (_asyncNotSupportedSource!=null)
    throw new IllegalStateException("!asyncSupported: "+_asyncNotSupportedSource);
  HttpChannelState state = getHttpChannelState();
  if (_async==null)
    _async=new AsyncContextState(state);
  AsyncContextEvent event = new AsyncContextEvent(_context,_async,state,this,servletRequest,servletResponse);
  event.setDispatchContext(getServletContext());
  
  String uri = ((HttpServletRequest)servletRequest).getRequestURI();
  if (_contextPath!=null && uri.startsWith(_contextPath))
    uri = uri.substring(_contextPath.length());
  else
    // TODO probably need to strip encoded context from requestURI, but will do this for now:
    uri = URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo()));  
  
  event.setDispatchPath(uri);
  state.startAsync(event);
  return _async;
}
origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server

public void handleAsync(HttpChannel connection) throws IOException, ServletException
{
  final HttpChannelState state = connection.getRequest().getHttpChannelState();
  final AsyncContextEvent event = state.getAsyncContextEvent();
  final Request baseRequest=connection.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.addPaths(context==null?null: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(request.getDispatcherType()+" "+request.getMethod()+" "+target+" on "+connection);
    handle(target, baseRequest, request, response);
    LOG.debug("RESPONSE "+target+"  "+connection.getResponse().getStatus());
  }
  else
    handle(target, baseRequest, request, response);
}
origin: Nextdoor/bender

public void handleAsync(HttpChannel<?> connection) throws IOException, ServletException
{
  final HttpChannelState state = connection.getRequest().getHttpChannelState();
  final AsyncContextEvent event = state.getAsyncContextEvent();
  final Request baseRequest=connection.getRequest();
  final String path=event.getPath();
  
  if (path!=null)
  {
    // this is a dispatch with a path
    ServletContext context=event.getServletContext();
    HttpURI uri = new HttpURI(URIUtil.addPaths(context==null?null:context.getContextPath(), path));            
    baseRequest.setUri(uri);
    baseRequest.setRequestURI(null);
    baseRequest.setPathInfo(uri.getDecodedPath());
    if (uri.getQuery()!=null)
      baseRequest.mergeQueryParameters(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(request.getDispatcherType()+" "+request.getMethod()+" "+target+" on "+connection);
    handle(target, baseRequest, request, response);
    LOG.debug("RESPONSE "+target+"  "+connection.getResponse().getStatus());
  }
  else
    handle(target, baseRequest, request, response);
}
origin: org.eclipse.jetty.aggregate/jetty-server

public void handleAsync(AbstractHttpConnection connection) throws IOException, ServletException
{
  final AsyncContinuation async = connection.getRequest().getAsyncContinuation();
  final AsyncContinuation.AsyncEventState state = async.getAsyncEventState();
  final Request baseRequest=connection.getRequest();
  final String path=state.getPath();
  if (path!=null)
  {
    // this is a dispatch with a path
    final String contextPath=state.getServletContext().getContextPath();
    HttpURI uri = new HttpURI(URIUtil.addPaths(contextPath,path));
    baseRequest.setUri(uri);
    baseRequest.setRequestURI(null);
    baseRequest.setPathInfo(baseRequest.getRequestURI());
    if (uri.getQuery()!=null)
      baseRequest.mergeQueryString(uri.getQuery()); //we have to assume dispatch path and query are UTF8
  }
  final String target=baseRequest.getPathInfo();
  final HttpServletRequest request=(HttpServletRequest)async.getRequest();
  final HttpServletResponse response=(HttpServletResponse)async.getResponse();
  if (LOG.isDebugEnabled())
  {
    LOG.debug("REQUEST "+target+" on "+connection);
    handle(target, baseRequest, request, response);
    LOG.debug("RESPONSE "+target+"  "+connection.getResponse().getStatus());
  }
  else
    handle(target, baseRequest, request, response);
}
origin: org.eclipse.jetty.aggregate/jetty-server

  throw new IllegalArgumentException();
if (!URIUtil.hasScheme(location))
  StringBuilder buf = _connection.getRequest().getRootURL();
  if (location.startsWith("/"))
    location=URIUtil.canonicalPath(location);
    String path=_connection.getRequest().getRequestURI();
    String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
    location=URIUtil.canonicalPath(URIUtil.addPaths(parent,location));
    if (!location.startsWith("/"))
      buf.append('/');
origin: org.eclipse.jetty.aggregate/jetty-all-server

public Resource getResource(String path) throws MalformedURLException
{
  if (path == null || !path.startsWith(URIUtil.SLASH))
    throw new MalformedURLException(path);
  if (_baseResource == null)
    return null;
  try
  {
    path = URIUtil.canonicalPath(path);
    Resource resource = _baseResource.addPath(path);
    
    if (checkAlias(path,resource))
      return resource;
    return null;
  }
  catch (Exception e)
  {
    LOG.ignore(e);
  }
  return null;
}
origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  url.append(getRequestURI());
  return url;
}
org.eclipse.jetty.utilURIUtil

Javadoc

URI Holder. This class assists with the decoding and encoding or HTTP URI's. It differs from the java.net.URL class as it does not provide communications ability, but it does assist with query string formatting.

UTF-8 encoding is used by default for % encoded characters. This may be overridden with the org.eclipse.jetty.util.URI.charset system property.

Most used methods

  • addPaths
    Add two URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSION
  • decodePath
  • encodePath
    Encode a URI path.
  • canonicalPath
    Convert a path to a cananonical form. All instances of "." and ".." are factored out. Null is return
  • compactPath
    Convert a path to a compact form. All instances of "//" and "///" etc. are factored out to single "/
  • hasScheme
  • parentPath
    Return the parent Path. Treat a URI like a directory path and return the parent directory.
  • appendSchemeHostPort
    Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports
  • newURI
    Create a new URI from the arguments, handling IPv6 host encoding and default ports
  • newURIBuilder
    Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports
  • addEncodedPaths
    Add two encoded URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;
  • equalsIgnoreEncodings
  • addEncodedPaths,
  • equalsIgnoreEncodings,
  • getJarSource,
  • addPath,
  • canonicalEncodedPath,
  • decodeISO88591Path

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now