Package org.eclipse.jetty.http

Examples of org.eclipse.jetty.http.HttpURI


        super("/", "0.0.0.0", 0);
    }
   
    @Override
    protected HttpURI proxyHttpURI(String scheme, String serverName, int serverPort, String uri) throws MalformedURLException {
        return new HttpURI("http://" + uri.replace("/proxy/", ""));
    }
View Full Code Here


        // add the dashboard startup timestamp header to the response.
        response.addHeader(WebServer.TIMESTAMP_HEADER, startupTimestamp);

        // make the URI canonical
        HttpURI uri = baseRequest.getUri();
        String origUri = uri.toString();
        String origPath = uri.getPath();

        String path = canonicalizePath(origPath);
        if (path == null || !path.startsWith("/") || path.contains("/../")) {
            baseRequest.setHandled(true);
            response.sendError(SC_BAD_REQUEST, "Bad filename.");
            return;
        }

        // Separate out the hierarchy prefix if the URI contains one
        String[] pathSplit = splitPath(path, "//", "/+/");
        String prefix = "";
        if (pathSplit != null) {
            prefix = pathSplit[0];
            path = pathSplit[1];
        }

        if (path.contains("//")) {
            baseRequest.setHandled(true);
            response.sendError(SC_BAD_REQUEST, "Bad path/filename.");
            return;
        }

        if (!origPath.equals(path)) {
            String newUri = replaceUriPath(origUri, origPath, path);
            if (newUri == null) {
                baseRequest.setHandled(true);
                response.sendError(SC_BAD_REQUEST, "Bad uri/filename.");
            } else {
                uri.parse(newUri);
            }
        }

        // add the "pdash" object to the request.
        baseRequest.setAttribute(PDashContext.REQUEST_ATTR,
View Full Code Here

        if (path!=null)
        {
            // this is a dispatch with a path
            ServletContext context=event.getServletContext();
            HttpURI uri = new HttpURI(context==null?path:URIUtil.addPaths(context.getContextPath(),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)event.getSuppliedRequest();
        final HttpServletResponse response=(HttpServletResponse)event.getSuppliedResponse();
View Full Code Here

        final Request request = _channel.getRequest();
        SessionManager sessionManager = request.getSessionManager();
        if (sessionManager == null)
            return url;

        HttpURI uri = null;
        if (sessionManager.isCheckingRemoteSessionIdEncoding() && URIUtil.hasScheme(url))
        {
            uri = new HttpURI(url);
            String path = uri.getPath();
            path = (path == null ? "" : path);
            int port = uri.getPort();
            if (port < 0)
                port = HttpScheme.HTTPS.asString().equalsIgnoreCase(uri.getScheme()) ? 443 : 80;
            if (!request.getServerName().equalsIgnoreCase(uri.getHost()) ||
                    request.getServerPort() != port ||
                    !path.startsWith(request.getContextPath())) //TODO the root context path is "", with which every non null string starts
                return url;
        }

        String sessionURLPrefix = sessionManager.getSessionIdPathParameterNamePrefix();
        if (sessionURLPrefix == null)
            return url;

        if (url == null)
            return null;

        // should not encode if cookies in evidence
        if ((sessionManager.isUsingCookies() && request.isRequestedSessionIdFromCookie()) || !sessionManager.isUsingURLs())
        {
            int prefix = url.indexOf(sessionURLPrefix);
            if (prefix != -1)
            {
                int suffix = url.indexOf("?", prefix);
                if (suffix < 0)
                    suffix = url.indexOf("#", prefix);

                if (suffix <= prefix)
                    return url.substring(0, prefix);
                return url.substring(0, prefix) + url.substring(suffix);
            }
            return url;
        }

        // get session;
        HttpSession session = request.getSession(false);

        // no session
        if (session == null)
            return url;

        // invalid session
        if (!sessionManager.isValid(session))
            return url;

        String id = sessionManager.getNodeId(session);

        if (uri == null)
            uri = new HttpURI(url);


        // Already encoded
        int prefix = url.indexOf(sessionURLPrefix);
        if (prefix != -1)
        {
            int suffix = url.indexOf("?", prefix);
            if (suffix < 0)
                suffix = url.indexOf("#", prefix);

            if (suffix <= prefix)
                return url.substring(0, prefix + sessionURLPrefix.length()) + id;
            return url.substring(0, prefix + sessionURLPrefix.length()) + id +
                    url.substring(suffix);
        }

        // edit the session
        int suffix = url.indexOf('?');
        if (suffix < 0)
            suffix = url.indexOf('#');
        if (suffix < 0)
        {
            return url +
                    ((HttpScheme.HTTPS.is(uri.getScheme()) || HttpScheme.HTTP.is(uri.getScheme())) && uri.getPath() == null ? "/" : "") + //if no path, insert the root path
                    sessionURLPrefix + id;
        }


        return url.substring(0, suffix) +
                ((HttpScheme.HTTPS.is(uri.getScheme()) || HttpScheme.HTTP.is(uri.getScheme())) && uri.getPath() == null ? "/" : "") + //if no path so insert the root path
                sessionURLPrefix + id + url.substring(suffix);
    }
View Full Code Here

                    buf.append('/');
                buf.append(location);
            }

            location = buf.toString();
            HttpURI uri = new HttpURI(location);
            String path = uri.getDecodedPath();
            String canonical = URIUtil.canonicalPath(path);
            if (canonical == null)
                throw new IllegalArgumentException();
            if (!canonical.equals(path))
            {
                buf = _channel.getRequest().getRootURL();
                buf.append(URIUtil.encodePath(canonical));
                String param=uri.getParam();
                if (param!=null)
                {
                    buf.append(';');
                    buf.append(param);
                }
                String query=uri.getQuery();
                if (query!=null)
                {
                    buf.append('?');
                    buf.append(query);
                }
                String fragment=uri.getFragment();
                if (fragment!=null)
                {
                    buf.append('#');
                    buf.append(fragment);
                }
View Full Code Here

        {
            // 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();
View Full Code Here

     * @see javax.servlet.ServletRequest#getServerPort()
     */
    @Override
    public int getServerPort()
    {
        HttpURI uri = _metadata.getURI();
        int port = (uri.getHost()==null)?findServerPort():uri.getPort();
           
        // If no port specified, return the default port for the scheme
        if (port <= 0)
        {
            if (getScheme().equalsIgnoreCase(URIUtil.HTTPS))
View Full Code Here

     */
    public void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
    {
        _metadata=request;
        setMethod(request.getMethod());
        HttpURI uri = request.getURI();
       
        String path = uri.getDecodedPath();
        String info;
        if (path==null || path.length()==0)
        {
            if (uri.isAbsolute())
            {
                path="/";
                uri.setPath(path);
            }
            else
            {
                setPathInfo("");
                throw new BadMessageException(400,"Bad URI");
View Full Code Here

   
    public JettyClient(HttpClient httpClient, String gatewayURI, String targetId)
    {
        super(targetId);
       
        HttpURI uri = new HttpURI(gatewayURI);
       
        this.httpClient = httpClient;
        this.gatewayAddress = new Address(uri.getHost(),uri.getPort());
        this.gatewayPath = uri.getPath();
    }
View Full Code Here

        long contentLength = requestContent == null ? -1 : requestContent.getLength();
        String path = request.getPath();
        String query = request.getQuery();
        if (query != null)
            path += "?" + query;
        MetaData.Request requestInfo = new MetaData.Request(request.getMethod(), new HttpURI(path), request.getVersion(), request.getHeaders(), contentLength);

        try
        {
            HttpClient client = getHttpChannel().getHttpDestination().getHttpClient();
            ByteBufferPool bufferPool = client.getByteBufferPool();
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.http.HttpURI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.