Examples of StringEndPoint


Examples of org.mortbay.io.bio.StringEndPoint

    }
   
    public void testHeaderParse()
  throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
            "GET / HTTP/1.0\015\012"
                + "Header1: value1\015\012"
                + "Header2  :   value 2a  \015\012"
                + "                    value 2b  \015\012"
                + "Header3: \015\012"
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testChunkParse()
      throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
            "GET /chunk HTTP/1.0\015\012"
                + "Header1: value1\015\012"
        + "Transfer-Encoding: chunked\015\012"
                + "\015\012"
                + "a;\015\012"
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testMultiParse()
    throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
            "GET /mp HTTP/1.0\015\012"
                + "Header1: value1\015\012"
        + "Transfer-Encoding: chunked\015\012"
                + "\015\012"
                + "a;\015\012"
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

        assertEquals("0123456789", _content);
    }

    public void testStreamParse() throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        String http="GET / HTTP/1.0\015\012"
                + "Header1: value1\015\012"
        + "Transfer-Encoding: chunked\015\012"
                + "\015\012"
                + "a;\015\012"
                + "0123456789\015\012"
                + "1a\015\012"
                + "ABCDEFGHIJKLMNOPQRSTUVWXYZ\015\012"
                + "0\015\012"
                + "POST /foo HTTP/1.0\015\012"
                + "Header2: value2\015\012"
                + "Content-Length: 0\015\012"
                + "\015\012"
                + "PUT /doodle HTTP/1.0\015\012"
                + "Header3: value3\015\012"
        + "Content-Length: 10\015\012"
                + "\015\012"
                + "0123456789\015\012";

       
        int[] tests=
            {
                1024,
                http.length() + 3,
                http.length() + 2,
                http.length() + 1,
                http.length() + 0,
                http.length() - 1,
                http.length() - 2,
                http.length() / 2,
                http.length() / 3,
                64,
                32
            };
       
        for (int t= 0; t < tests.length; t++)
        {
            String tst="t"+tests[t];
            try
            {
                ByteArrayBuffer buffer= new ByteArrayBuffer(tests[t]);
                ByteArrayBuffer content=new ByteArrayBuffer(8192);
                SimpleBuffers buffers=new SimpleBuffers(new Buffer[]{buffer,content});

                Handler handler = new Handler();
                HttpParser parser= new HttpParser(buffers,io, handler, buffer.capacity(), content.capacity());
               
               
                io.setInput(http);
               
                parser.parse();
                assertEquals(tst,"GET", f0);
                assertEquals(tst,"/", f1);
                assertEquals(tst,"HTTP/1.0", f2);
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testResponseParse0()
  throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
      "HTTP/1.1 200 Correct\015\012"
      + "Content-Length: 10\015\012"
      + "Content-Type: text/plain\015\012"
      + "\015\012"
      + "0123456789\015\012");
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testResponseParse1()
  throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
      "HTTP/1.1 304 Not-Modified\015\012"
      + "Connection: close\015\012"
      + "\015\012");
        ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
        SimpleBuffers buffers=new SimpleBuffers(new Buffer[]{buffer});
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testResponseParse2()
  throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput(
      "HTTP/1.1 204 No-Content\015\012"
      + "Connection: close\015\012"
      + "\015\012"
      + "HTTP/1.1 200 Correct\015\012"
      + "Content-Length: 10\015\012"
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

            //System.err.println(chunk);
            request+=chunk;
        }
       

        StringEndPoint io=new StringEndPoint();
        io.setInput(request);
        ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
        SimpleBuffers buffers=new SimpleBuffers(new Buffer[]{buffer});

        Handler handler = new Handler()
        {
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

    }

    public void testLineParse0()
  throws Exception
    {
        StringEndPoint io=new StringEndPoint();
        io.setInput("POST /foo HTTP/1.0\015\012" + "\015\012");
        ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
        SimpleBuffers buffers=new SimpleBuffers(new Buffer[]{buffer});

        Handler handler = new Handler();
        HttpParser parser= new HttpParser(buffers,io, handler, buffer.capacity(), 0);
View Full Code Here

Examples of org.mortbay.io.bio.StringEndPoint

            if(charset!=null)
                _charset = charset;
        }
        Buffer bb=new ByteArrayBuffer(32*1024 + (_genContent!=null?_genContent.length:0));
        Buffer sb=new ByteArrayBuffer(4*1024);
        StringEndPoint endp = new StringEndPoint(_charset);
        HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
       
        if (_method!=null)
        {
            generator.setRequest(getMethod(),getURI());
            if (_version==null)
                generator.setVersion(HttpVersions.HTTP_1_1_ORDINAL);
            else
                generator.setVersion(HttpVersions.CACHE.getOrdinal(HttpVersions.CACHE.lookup(_version)));
            generator.completeHeader(_fields,false);
            if (_genContent!=null)
                generator.addContent(new View(new ByteArrayBuffer(_genContent)),false);
            else if (_parsedContent!=null)
                generator.addContent(new ByteArrayBuffer(_parsedContent.toByteArray()),false);
        }
       
        generator.complete();
        generator.flush();
        return endp.getOutput();
    }
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.