Package org.mortbay.jetty

Examples of org.mortbay.jetty.HttpURI


    }

    /* ------------------------------------------------------------ */
    public BayeuxClient(HttpClient client, String url, Timer timer)
    {
        HttpURI uri = new HttpURI(url);
        _httpClient = client;
        _cometdAddress = new Address(uri.getHost(),uri.getPort());
        _path=uri.getPath();
        _timer = timer;
        _scheme = (HttpSchemes.HTTPS.equals(uri.getScheme()))?HttpSchemes.HTTPS_BUFFER:HttpSchemes.HTTP_BUFFER;
    }
View Full Code Here


   
    private int _maxRequestMs = 200;
    protected void setUp() throws Exception
    {
        _tester = new ServletTester();
        HttpURI uri=new HttpURI(_tester.createSocketConnector(true));
        _host=uri.getHost();
        _port=uri.getPort();
       
        _tester.setContextPath("/ctx");
        _tester.addServlet(TestServlet.class, "/*");
       
        FilterHolder dos=_tester.addFilter(DoSFilter2.class,"/dos/*",0);
 
View Full Code Here

    "<p>'So much for the 0% chance of rain,' I repeated.</p></body></html>";

  @Override
  public void handle(Request req, HttpServletResponse res, String target,
          int dispatch) throws IOException, ServletException {
    HttpURI u = req.getUri();
    String uri = u.toString();
    //System.err.println("-faking " + uri.toString());
    addMyHeader(res, "URI", uri);
    // don't pass it down the chain
    req.setHandled(true);
    res.addHeader("X-Handled-By", getClass().getSimpleName());
    if (uri.endsWith("/robots.txt")) {
      return;
    }
    res.setContentType("text/html");
    try {
      OutputStream os = res.getOutputStream();
      byte[] bytes = testA.getBytes("UTF-8");
      os.write(bytes);
      // record URI
      String p = "<p>URI: " + uri + "</p>\r\n";
      os.write(p.getBytes());
      // fake some links
      String base;
      if (u.getPath().length() > 5) {
        base = u.getPath().substring(0, u.getPath().length() - 5);
      } else {
        base = u.getPath();
      }
      String prefix = u.getScheme() + "://" + u.getHost();
      if (u.getPort() != 80 && u.getPort() != -1) base += ":" + u.getPort();
      if (!base.startsWith("/")) prefix += "/";
      prefix = prefix + base;
      for (int i = 0; i < 10; i++) {
        String link = "<p><a href='" + prefix;
        if (!prefix.endsWith("/")) {
          link += "/";
        }
        link += i + ".html'>outlink " + i + "</a></p>\r\n";
        os.write(link.getBytes());
      }
      // fake a few links to random nonexistent hosts
      for (int i = 0; i < 5; i++) {
        int h = r.nextInt(1000000); // 1 mln hosts
        String link = "<p><a href='http://www.fake-" + h + ".com/'>fake host " + h + "</a></p>\r\n";
        os.write(link.getBytes());
      }
      // fake a link to the root URL
      String link = "<p><a href='" + u.getScheme() + "://" + u.getHost();
      if (u.getPort() != 80 && u.getPort() != -1) link += ":" + u.getPort();
      link += "/'>site " + u.getHost() + "</a></p>\r\n";
      os.write(link.getBytes());
      os.write(testB.getBytes());
      res.flushBuffer();
    } catch (IOException ioe) {
    }   
View Full Code Here

  }
 
  @Override
  public void handle(Request req, HttpServletResponse res, String target,
          int dispatch) throws IOException, ServletException {
    HttpURI u = req.getUri();
    String uri = u.toString();
    addMyHeader(res, "URI", uri);
    // don't pass it down the chain
    req.setHandled(true);
    res.addHeader("X-Handled-By", getClass().getSimpleName());
    if (uri.endsWith("/robots.txt")) {
      return;
    }
    res.setContentType("text/html");
    try {
      OutputStream os = res.getOutputStream();
      byte[] bytes = testA.getBytes("UTF-8");
      os.write(bytes);
      // record URI
      String p = "<p>URI: " + uri + "</p>\r\n";
      os.write(p.getBytes());
      // fake some links
      String basePath;
      String baseDomain;
      if (u.getPath().length() > 5) {
        basePath = u.getPath().substring(0, u.getPath().length() - 5);
      } else {
        basePath = u.getPath();
      }
      // internal links
      if (pageMode.equals(Mode.RANDOM)) { // initialize random per host
        pageR = new Random(u.getHost().hashCode());
      }
      for (int i = 0; i < numInternalLinks; i++) {
        String link = "<p><a href='";
        if (pageMode.equals(Mode.RANDOM)) {
          link += pageR.nextInt (numPages) + ".html'>";
        } else {
          if (!basePath.endsWith("/")) {
            link += "/";
          }
          link += pageSeq.getAndIncrement() + ".html'>";
        }
        link += "outlink " + i + "</a></p>\r\n";
        os.write(link.getBytes());
      }
      baseDomain = u.getHost();
      // chop off the TLD
      int pos = baseDomain.lastIndexOf('.');
      String tld = baseDomain.substring(pos);
      baseDomain = baseDomain.substring(0, pos);
      String link;
      // external links
      for (int i = 0; i < numExternalLinks; i++) {
        String host;
        if (hostMode.equals(Mode.RANDOM)) {
          host = "www.rnd-" + r.nextInt(numHosts) + ".com";
          link = "http://" + host + "/";
        } else {
          host = baseDomain + "-" + hostSeq.getAndIncrement() + ".com";
          link = "http://" + host + "/";
        }
        link = "<p><a href='" + link + "'>fake host " + host + "</a></p>\r\n";
        os.write(link.getBytes());
      }
      // fake a link to the root URL
      link = "<p><a href='" + u.getScheme() + "://" + u.getHost();
      if (u.getPort() != 80 && u.getPort() != -1) link += ":" + u.getPort();
      link += "/'>site " + u.getHost() + "</a></p>\r\n";
      os.write(link.getBytes());
      os.write(testB.getBytes());
      res.flushBuffer();
    } catch (IOException ioe) {
    }   
View Full Code Here

        address = endpoint.getHttpUri().toString();

        // A workaround where the Jetty client does not like to see
        // urls like http://google.com but does like http://google.com/
        HttpURI uri = new HttpURI(address);
        if (uri.getCompletePath() == null) {
            address += "/";
        }
    }
View Full Code Here

        address = endpoint.getHttpUri().toString();

        // A workaround where the Jetty client does not like to see
        // urls like http://google.com but does like http://google.com/
        HttpURI uri = new HttpURI(address);
        if (uri.getCompletePath() == null) {
            address += "/";
        }
    }
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.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.