Package org.apache.tomcat.lite.io

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


            updateKeepAlive(http.getResponse().getMimeHeaders(), false);

            if (statusDropsConnection(http.getResponse().getStatus())) {
                closeStreamOnEnd("response status drops connection");
            }
            IOBuffer body = http.receiveBody;
            processContentDelimitation(receiveBodyState, http.getResponse());

            if (isDone(receiveBodyState, body)) {
                body.close();
            }

            if (!receiveBodyState.isContentDelimited()) {
                closeStreamOnEnd("not content delimited");
            }
View Full Code Here


        if (!serverMode) {
            throw new IOException("Only in server mode");
        }
        endSent = false;
        IOBuffer sendBody = http.sendBody;
        HttpResponse res = http.getResponse();
        if (res.isCommitted()) {
            return;
        }
        res.setCommitted(true);

        sendBodyState.noBody = !res.hasBody();

        if (statusDropsConnection(res.getStatus())) {
            closeStreamOnEnd("status drops connection");
        }
        if (http.error) {
            closeStreamOnEnd("error");
        }

        MultiMap headers = res.getMimeHeaders();

        // Add date header
        if (headers.getHeader("Date") == null) {
            headers.setValue("Date").set(FastHttpDateFormat.getCurrentDate());
        }

        // Add server header
        if (http.serverHeader.length() > 0) {
            headers.setValue("Server").set(http.serverHeader);
        }

        // Decide on a transfer encoding for out.
        if (keepAlive()) { // request and user allows keep alive
            int cl = res.getContentLength();

            if (http10) {
                if (cl < 0 && !sendBodyState.noBody &&
                        sendBody.isAppendClosed()) {
                    // We can generate content-lenght
                    cl = sendBody.available();
                    res.setContentLength(cl);
                }
                if (cl < 0 && !sendBodyState.noBody) {
                    closeStreamOnEnd("HTTP/1.0 without content length");
                } else {
View Full Code Here

public class CompressFilterTest extends TestCase {

    CompressFilter cf = new CompressFilter();

    private void check(String clear, String xtra) throws Exception {
        IOBuffer in = new IOBuffer();
        IOBuffer out = new IOBuffer();

        in.append(clear);
        in.close();

        cf.compress(in, out);

//        BBuffer bb = out.copyAll(null);
//        String hd = Hex.getHexDump(bb.array(), bb.position(),
//                bb.remaining(), true);
//        System.err.println(hd);

        if (xtra != null) {
            out.append(xtra);
        }
        in.recycle();
        out.close();
        cf.decompress(out, in);

        assertEquals(in.copyAll(null).toString(), clear);
        assertTrue(in.isAppendClosed());

        if (xtra != null) {
            assertEquals(out.copyAll(null).toString(), xtra);
        }
    }
View Full Code Here

        getCharEncoder().encodeAll(cb, bb, "UTF-8");
        return bb;
    }

    public String toString() {
        IOBuffer out = new IOBuffer();
        try {
            Http11Connection.serialize(this, out);
            return out.readAll(null).toString();
        } catch (IOException e) {
            return "Invalid request";
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tomcat.lite.io.IOBuffer

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.