Examples of ByteArrayEndPoint


Examples of org.mortbay.io.ByteArrayEndPoint

    public void testContentLength()
        throws Exception
    {
        Buffer bb=new ByteArrayBuffer(8096);
        Buffer sb=new ByteArrayBuffer(1500);
        ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
        HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
       
        generator.setRequest("GET","/usr");
       
        HttpFields fields = new HttpFields();
        fields.add("Header","Value");
        fields.add("Content-Type","text/plain");
       
        String content = "The quick brown fox jumped over the lazy dog";
        fields.addLongField("Content-Length",content.length());
       
        generator.completeHeader(fields,false);
       
        generator.addContent(new ByteArrayBuffer(content),true);
        generator.flush();
        generator.complete();
        generator.flush();
       
        String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
        assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
    }
View Full Code Here

Examples of org.mortbay.io.ByteArrayEndPoint

    public void testAutoContentLength()
        throws Exception
    {
        Buffer bb=new ByteArrayBuffer(8096);
        Buffer sb=new ByteArrayBuffer(1500);
        ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
        HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
       
        generator.setRequest("GET","/usr");
       
        HttpFields fields = new HttpFields();
        fields.add("Header","Value");
        fields.add("Content-Type","text/plain");
       
        String content = "The quick brown fox jumped over the lazy dog";

        generator.addContent(new ByteArrayBuffer(content),true);
        generator.completeHeader(fields,true);
       
        generator.flush();
        generator.complete();
        generator.flush();
       
        String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
        assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
    }
View Full Code Here

Examples of org.mortbay.io.ByteArrayEndPoint

    public void testChunked()
        throws Exception
    {
        Buffer bb=new ByteArrayBuffer(8096);
        Buffer sb=new ByteArrayBuffer(1500);
        ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
        HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
       
        generator.setRequest("GET","/usr");
       
        HttpFields fields = new HttpFields();
        fields.add("Header","Value");
        fields.add("Content-Type","text/plain");
       
        String content = "The quick brown fox jumped over the lazy dog";

        generator.completeHeader(fields,false);
       
        generator.addContent(new ByteArrayBuffer(content),false);
        generator.flush();
        generator.complete();
        generator.flush();
       
        String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
        assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Transfer-Encoding: chunked||2C|"+content+"|0||",result);
    }
View Full Code Here

Examples of org.mortbay.io.ByteArrayEndPoint

      throws Exception
    {
        Buffer bb=new ByteArrayBuffer(8096);
        Buffer sb=new ByteArrayBuffer(1500);
        HttpFields fields = new HttpFields();
        ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
        HttpGenerator hb = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
        Handler handler = new Handler();
        HttpParser parser=null;
       
        // For HTTP version
        for (int v=9;v<=11;v++)
        {
            // For each test result
            for (int r=0;r<tr.length;r++)
            {
                // chunks = 1 to 3
                for (int chunks=1;chunks<=6;chunks++)
                {
                    // For none, keep-alive, close
                    for (int c=0;c<(v==11?connect.length:(connect.length-1));c++)
                    {
                       
                        String t="v="+v+",r="+r+",chunks="+chunks+",connect="+connect[c]+",tr="+tr[r];
                        // System.err.println(t);
                       
                        hb.reset(true);
                        endp.reset();
                        fields.clear();
                       
                        tr[r].build(v,hb,"OK\r\nTest",connect[c],null,chunks, fields);
                        String response=endp.getOut().toString();
                        // System.out.println("RESPONSE: "+t+"\n"+response+(hb.isPersistent()?"...\n":"---\n"));
                       
                        if (v==9)
                        {
                            assertFalse(t,hb.isPersistent());
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.