Examples of BBuffer


Examples of org.apache.tomcat.lite.io.BBuffer

    /**
     * Blocking get, returns when the body has been read.
     */
    public static BBuffer get(String url) throws IOException {

        BBuffer out = BBuffer.allocate();

        HttpRequest aclient = HttpClient.newClient().request(url);
        aclient.send();
        aclient.readAll(out,
                //Long.MAX_VALUE);//
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

        aclient.release(); // return connection to pool
        return out;
    }

    public static BBuffer getUrl(String path) throws IOException {
        BBuffer out = BBuffer.allocate();
        getUrl(path, out);
        return out;
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

        HttpChannel ch = clientCon.get("localhost", port);
        ch.getRequest().setRequestURI("/index.html");
        ch.getRequest().send();

        BBuffer res = ch.readAll(null, 0);

        assertTrue(res.toString(),
                res.toString().indexOf("<title>Apache Tomcat</title>") >= 0);
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

    BBuffer f3 = BBuffer.wrapper("GET /a?b HTTP/1.0\na:b\r\r");
    BBuffer f4 = BBuffer.wrapper("GET /a?b HTTP/1.0\na:b\r\n\r");

    public void reqTest(String lineS, String method, String req,
            String qry, String proto) throws IOException {
        BBuffer line = BBuffer.wrapper(lineS);
        queryB.recycle();
        protoB.recycle();
        requestB.recycle();
        methodB.recycle();
        con.parseRequestLine(line, methodB, requestB, queryB, protoB);
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

        MultiMap params = processQry("a=b&c=d");
        assertEquals("b", params.getString("a"));
    }

    private MultiMap processQry(String qry) throws IOException {
        BBuffer head = BBuffer.wrapper("GET /a?" + qry + " HTTP/1.0\n" +
            "Host: a\n\n");
        con.parseMessage(ch, head);
        MultiMap params = req.getParameters();
        return params;
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

    public void responseTest(String lineS, String proto, String status,
            String msg) throws IOException {
        protoB.recycle();
        statusB.recycle();
        msgB.recycle();
        BBuffer line = BBuffer.wrapper(lineS);
        con.parseResponseLine(line,
                protoB, statusB, msgB);
        assertEquals(proto, protoB.toString());
        assertEquals(status, statusB.toString());
        assertEquals(msg, msgB.toString());
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

        checkResponse(httpClient);
    }

    public void testSimpleServer() throws Exception {
        final HttpConnector httpClient = TestMain.shared().getClient();
        BBuffer res = TestMain.getUrl("https://localhost:8443/hello");
        assertTrue(res.toString().indexOf("Hello") >= 0);
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

        HttpRequest ch = httpCon.request("localhost", port).setSecure(true);

        ch.setRequestURI("/hello");
        ch.setProtocol("HTTP/1.0"); // to force close
        ch.send();
        BBuffer res = ch.readAll();

        assertTrue(res.toString().indexOf("Hello") >= 0);
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

            setSecure(true);
        client.getHttpChannel().setIOTimeout(2000000);
        client.setRequestURI("/accounts/ServiceLogin");
        client.send();

        BBuffer res = client.readAll();
        assertTrue(res.toString().indexOf("<title>Google Accounts</title>") > 0);
        }
    }
View Full Code Here

Examples of org.apache.tomcat.lite.io.BBuffer

    }

    public void setFile(String path) {
      try {
        FileInputStream fis = new FileInputStream(path);
        BBuffer bc = BBuffer.allocate(4096);

        byte b[] = new byte[4096];
        int rd = 0;
        while ((rd = fis.read(b)) > 0) {
            bc.append(b, 0, rd);
        }
        mb = bc;
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
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.