Package org.mortbay.io

Examples of org.mortbay.io.Buffer


            _calendar = new GregorianCalendar(__GMT);
        }
        _dateBuffer.setLength(0);
        _calendar.setTimeInMillis(date);
        formatDate(_dateBuffer, _calendar, false);
        Buffer v = new ByteArrayBuffer(_dateBuffer.toString());
        put(name, v, date);
    }
View Full Code Here


     * @param name the field name
     * @param date the field date value
     */
    public void putDateField(String name, long date)
    {
        Buffer n = HttpHeaders.CACHE.lookup(name);
        putDateField(n,date);
    }
View Full Code Here

            _calendar = new GregorianCalendar(__GMT);
        }
        _dateBuffer.setLength(0);
        _calendar.setTimeInMillis(date);
        formatDate(_dateBuffer, _calendar, false);
        Buffer n = HttpHeaders.CACHE.lookup(name);
        Buffer v = new ByteArrayBuffer(_dateBuffer.toString());
        add(n, v, date);
    }
View Full Code Here

    }
   
    public void testHTTP()
      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++)
View Full Code Here

    }

    public void testOutput()
        throws Exception
    {
        Buffer sb=new ByteArrayBuffer(1500);
        Buffer bb=new ByteArrayBuffer(8096);
        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());

        hb.setResponse(200,"OK");
       
        Output output = new Output(hb,10000);
        OutputWriter writer = new OutputWriter(output);
View Full Code Here

            }
                       
            if (body!=null)
            {
                int inc=1+body.length()/chunks;
                Buffer buf=new ByteArrayBuffer(body);
                View view = new View(buf);
                for (int i=1;i<chunks;i++)
                {
                    view.setPutIndex(i*inc);
                    view.setGetIndex((i-1)*inc);
                    hb.addContent(view,HttpGenerator.MORE);
                    if (hb.isBufferFull() && hb.isState(HttpGenerator.STATE_HEADER))
                        hb.completeHeader(fields, HttpGenerator.MORE);
                    if (i%2==0)
                    {
                        if (hb.isState(HttpGenerator.STATE_HEADER))
                            hb.completeHeader(fields, HttpGenerator.MORE);
                        hb.flush();
                    }
                }
                view.setPutIndex(buf.putIndex());
                view.setGetIndex((chunks-1)*inc);
                hb.addContent(view,HttpGenerator.LAST);
                if(hb.isState(HttpGenerator.STATE_HEADER))
                    hb.completeHeader(fields, HttpGenerator.LAST);
            }
View Full Code Here

       
        if (_last || _state==STATE_END)
            return -1;

        // Handle any unfinished business?
        Buffer content = _content;
        if (content != null && content.length()>0 || _bufferChunked)
        {
            flush();
            if (content != null && content.length()>0 || _bufferChunked)
                throw new IllegalStateException("FULL");
        }

        // we better check we have a buffer
        if (_buffer == null)
View Full Code Here

            {
                if (_version == HttpVersions.HTTP_1_0_ORDINAL)
                    _close = true;

                // add response line
                Buffer line = HttpStatus.getResponseLine(_status);

               
                if (line==null)
                {
                    if (_reason==null)
                        _reason=getReasonBuffer(_status);

                    _header.put(HttpVersions.HTTP_1_1_BUFFER);
                    _header.put((byte) ' ');
                    _header.put((byte) ('0' + _status / 100));
                    _header.put((byte) ('0' + (_status % 100) / 10));
                    _header.put((byte) ('0' + (_status % 10)));
                    _header.put((byte) ' ');
                    if (_reason==null)
                    {
                        _header.put((byte) ('0' + _status / 100));
                        _header.put((byte) ('0' + (_status % 100) / 10));
                        _header.put((byte) ('0' + (_status % 10)));
                    }
                    else
                        _header.put(_reason);
                    _header.put(HttpTokens.CRLF);
                }
                else
                {
                    if (_reason==null)
                        _header.put(line);
                    else
                    {
                        _header.put(line.array(), 0, HttpVersions.HTTP_1_1_BUFFER.length() + 5);
                        _header.put(_reason);
                        _header.put(HttpTokens.CRLF);
                    }
                }
View Full Code Here

        // + Will it be possible to get a DIRECT header buffer just for the gather writes of
        // content from file mapped buffers? 
        // + Are gather writes worth the effort?  Maybe they will work well with two INDIRECT
        // buffers being copied into a single kernel buffer?
        //
        Buffer buf = null;
        if (size==getHeaderBufferSize())
            buf= new IndirectNIOBuffer(size);
        else
            buf = _useDirectBuffers
                ?(NIOBuffer)new DirectNIOBuffer(size)
View Full Code Here

     * @return MIME type matching the longest dot extension of the
     * file name.
     */
    public Buffer getMimeByExtension(String filename)
    {
        Buffer type=null;

        if (filename!=null)
        {
            int i=-1;
            while(type==null)
View Full Code Here

TOP

Related Classes of org.mortbay.io.Buffer

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.