Examples of IHttpServer


Examples of org.xlightweb.server.IHttpServer

    @Test
    public void testNonThreaded() throws Exception {

        NonThreadedRequestHandler requestHdl = new NonThreadedRequestHandler();
        IHttpServer server = new HttpServer(requestHdl);
        server.start();
     
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("GET /test HTTP/1.1\r\n" +
                  "User-Agent: me\r\n" +
                  "Host: localhost:" + server.getLocalPort() + "\r\n\r\n");
       
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("200") != -1);
       
        Assert.assertFalse(requestHdl.threadnameRef.get().startsWith("xServerPool"));
               
        con.close();
        server.close();
    }   
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

   
    @Test
    public void testMultiThreaded() throws Exception {

        MultiThreadedRequestHandler requestHdl = new MultiThreadedRequestHandler();
        IHttpServer server = new HttpServer(requestHdl);
        server.start();
     
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("GET /test HTTP/1.1\r\n" +
                  "User-Agent: me\r\n" +
                  "Host: localhost:" + server.getLocalPort() + "\r\n\r\n");
       
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("200") != -1);
             
        Assert.assertTrue(requestHdl.threadnameRef.get().startsWith("xServerPool"));
       
        con.close();
        server.close();
    }   
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

    chain.addLast(h1);
   
    RequestHandler h2 = new RequestHandler("/bs");
    chain.addLast(h2);

    IHttpServer server = new HttpServer(chain);
    server.start();
   
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
   
    con.write("GET /test HTTP/1.1\r\n" +
              "Host: localhost:" + server.getLocalPort() + "\r\n" +
              "User-Agent: me\r\n\r\n");
   
    String header = con.readStringByDelimiter("\r\n\r\n");
    Assert.assertTrue(header.indexOf("200") != -1);
    Assert.assertFalse(h1.isForwardedRef.get());
   
    h1.reset();
    h2.reset();
    con.close();
   
    con = new BlockingConnection("localhost", server.getLocalPort());
    con.write("GET /bs HTTP/1.1\r\n" +
                "Host: localhost:" + server.getLocalPort() + "\r\n" +
                "User-Agent: me\r\n\r\n");
     
    header = con.readStringByDelimiter("\r\n\r\n");
    Assert.assertTrue(header.indexOf("200") != -1);
    Assert.assertTrue(h1.isForwardedRef.get());
      Assert.assertFalse(h2.isForwardedRef.get());
     
        con.close();
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

        chain.addLast(h1);
       
        RequestHandler h2 = new RequestHandler("/bs");
        chain.addLast(h2);

        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
       
       
        con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("GET /bs HTTP/1.1\r\n" +
                "Host: localhost:" + server.getLocalPort() + "\r\n" +
                "User-Agent: me\r\n\r\n");
     
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("200") != -1);
        Assert.assertTrue(h1.isForwardedRef.get());
        Assert.assertFalse(h2.isForwardedRef.get());
       
        h1.reset();
        h2.reset();
       
        con.close();
        server.close();  
    }
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

        chain.addLast(h1);
       
        RequestHandler h2 = new RequestHandler("/bs");
        chain.addLast(h2);

        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
       
        con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("GET /tztz HTTP/1.1\r\n" +
                "Host: localhost:" + server.getLocalPort() + "\r\n" +
                "User-Agent: me\r\n\r\n");
     
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("404") != -1);
        Assert.assertTrue(h1.isForwardedRef.get());
        Assert.assertTrue(h2.isForwardedRef.get());
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

                dataSink.close();
            }
        };
        chain.addLast(rh);
       
        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
       
        con.write("GET /test HTTP/1.1\r\n" +
                  "Host: localhost:" + server.getLocalPort() + "\r\n" +
                  "User-Agent: me\r\n\r\n");
       
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("200") != -1);
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

            }
        };
        chain.addLast(rh2);

       
        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
       
        con.write("POST /test HTTP/1.1\r\n" +
                  "Host: localhost:" + server.getLocalPort() + "\r\n" +
                  "User-Agent: me\r\n" +
                  "Content-Length: 5\r\n" +
                  "\r\n" +
                  "12345");
       
        String header = con.readStringByDelimiter("\r\n\r\n");
        Assert.assertTrue(header.indexOf("200") != -1);
       
        QAUtil.sleep(1000);
        Assert.assertEquals("addedLine\r\n12345", con.readStringByLength(16));
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.server.IHttpServer

     
        RequestHandlerChain chain = new RequestHandlerChain();
        chain.addLast(new LogFilter());
        chain.addLast(forwardHdl);
       
        IHttpServer proxy = new HttpServer(chain);
        proxy.start();
     
      IBlockingConnection con = new BlockingConnection("localhost", proxy.getLocalPort());
      con.write("GET http://localhost:" + srv.getLocalPort() + "/ HTTP/1.1\r\n" +
                "Keep-Alive: 300\r\n" +
                "Host: localhost:" + srv.getLocalPort() + "\r\n" +
                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8\r\n" +
                "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" +
                "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n" +
                "Accept-Encoding: gzip,deflate\r\n" +
                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" +
                "Proxy-Connection: keep-alive\r\n" +
                "Cookie: RMID=54adb69c49d4fe30; RMFD=011LwE8hO20bs9|O10btZ|O20cCh|O20cFU|P10cIy;\r\n" +
                " POPUPCHECK=1240399709578; RMFW=011LvnI7710cJZ; RMFM=011LwEEAC20cI1; RMFS=011LwFk0U20Zv3; RMFL=011Lse0NU10cJD|U30cJE; mpt_vid=124006166948487470; mpt_rec_ign=true\r\n" +
                "\r\n");

      String header = con.readStringByDelimiter("\r\n\r\n");
      Assert.assertTrue(header.indexOf("HTTP/1.0 301 Moved Permanently") != -1);
     
      con.close();
      proxy.close();
      srv.close();
     
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.