Package net.lightbody.bmp.proxy.jetty.util

Examples of net.lightbody.bmp.proxy.jetty.util.URI


     * 2. Store the original hostname in a ThreadLocal so we don't need to do the same string processing again later
     * 2. Set the URI to 127.0.0.1 to pass into Odo
     * 3. Call the original handleConnect from SeleniumProxyHandler(copied to handle an Odo SslRelay)
     */
    public void handleConnect(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException {
        URI uri = request.getURI();
        String original = uri.toString();
        LOG.info("Hostname: " + original);
        String host = original;
        String port = null;
        int colon = original.indexOf(':');
        if (colon != -1) {
            host = original.substring(0, colon);
            port = original.substring(colon + 1);
        }
       
        // store the original host name
        requestOriginalHostName.set(host);
       
        // make a copy of the URI(have to create a new URI otherwise things are copied by reference and get changed)
        URI realURI = new URI(request.getURI());
        requestOriginalURI.set(realURI);
       
      // send requests to Odo HTTPS port
        int httpsPort = com.groupon.odo.proxylib.Utils.GetSystemPort(Constants.SYS_HTTPS_PORT);
      uri.setURI("127.0.0.1:" + httpsPort);
View Full Code Here


     * @param response
     * @throws HttpException
     * @throws IOException
     */
    public void handleConnectOriginal(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException {
        URI uri = request.getURI();

        try {
            LOG.fine("CONNECT: " + uri);
            InetAddrPort addrPort;
            // When logging, we'll attempt to send messages to hosts that don't exist
            if (uri.toString().endsWith(".selenium.doesnotexist:443")) {
                // so we have to do set the host to be localhost (you can't new up an IAP with a non-existent hostname)
                addrPort = new InetAddrPort(443);
            } else {
                addrPort = new InetAddrPort(uri.toString());
            }

            if (isForbidden(HttpMessage.__SSL_SCHEME, addrPort.getHost(), addrPort.getPort(), false)) {
                sendForbid(request, response, uri);
            } else {
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    private SslRelayOdo getSslRelayOrCreateNewOdo(URI uri, InetAddrPort addrPort, HttpServer server) throws Exception {
      URI realURI = requestOriginalURI.get();
      InetAddrPort realPort = new InetAddrPort(realURI.toString());
      LOG.info("GETSSLRELAY: {}, {}", realURI, realPort);
      String host = new URL("https://" + realURI.toString()).getHost();
     
      // create a host and port string so the listener sslMap can be keyed off the combination
      String hostAndPort = host.concat(String.valueOf(realPort.getPort()));
      LOG.info("getSSLRelay host: {}", hostAndPort);
      SslRelayOdo listener = null;
View Full Code Here

        }

        protected void customizeRequest(Socket socket, HttpRequest request)
        {
            super.customizeRequest(socket,request);
            URI uri=request.getURI();

            // Convert the URI to a proxy URL
            //
            // NOTE: Don't just add a host + port to the request URI, since this causes the URI to
            // get "dirty" and be rewritten, potentially breaking the proxy slightly. Instead,
            // create a brand new URI that includes the protocol, the host, and the port, but leaves
            // intact the path + query string "as is" so that it does not get rewritten.
            request.setURI(new URI("https://" + _addr.getHost() + ":" + _addr.getPort() + uri.toString()));
        }
View Full Code Here

TOP

Related Classes of net.lightbody.bmp.proxy.jetty.util.URI

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.