Examples of CBuffer


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

            }
            return;
        }


        CBuffer origURIx = serverHttpReq.requestURI();
//        String origURI = origURIx.toString();
//        if (origURI.startsWith("http://")) {
//            // Real proxy - extract client address, modify the uri.
//            // TODO: optimize the strings.
//            int start = origURI.indexOf('/', 7);
//            String hostPortS = (start == -1) ?
//                    origURI.subSequence(7, origURI.length()).toString() :
//                    origURI.subSequence(7, start).toString();
//            String[] hostPort = hostPortS.split(":");
//
//            dstHost = hostPort[0];
//            dstPort = (hostPort.length > 1) ? Integer.parseInt(hostPort[1]) :
//                80;
//
//            if (start >= 0) {
//                serverHttpReq.requestURI().set(origURI.substring(start));
//            } else {
//                serverHttpReq.requestURI().set("/");
//            }
//        } else {
            // Adjust the host header.
            CBuffer hostHdr =
                serverHttpReq.getMimeHeaders().getHeader("host");
            if (hostHdr != null) {
                hostHdr.recycle();
                CBuffer cb = hostHdr;
                cb.append(dstHost);
                if (dstPort != 80) {
                    cb.append(':');
                    cb.appendInt(dstPort);
                }
            }
//        }
        if (debug) {
            HttpChannel server = serverHttpReq.getHttpChannel();
View Full Code Here

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


    static void copyHeaders(MultiMap mimeHeaders, MultiMap dest)
            throws IOException {
        for (int i = 0; i < mimeHeaders.size(); i++) {
            CBuffer name = mimeHeaders.getName(i);
            CBuffer val = dest.addValue(name.toString());
            val.set(mimeHeaders.getValue(i));
        }
    }
View Full Code Here

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

            }
            return;
        }


        CBuffer origURIx = serverHttpReq.requestURI();
//        String origURI = origURIx.toString();
//        if (origURI.startsWith("http://")) {
//            // Real proxy - extract client address, modify the uri.
//            // TODO: optimize the strings.
//            int start = origURI.indexOf('/', 7);
//            String hostPortS = (start == -1) ?
//                    origURI.subSequence(7, origURI.length()).toString() :
//                    origURI.subSequence(7, start).toString();
//            String[] hostPort = hostPortS.split(":");
//
//            dstHost = hostPort[0];
//            dstPort = (hostPort.length > 1) ? Integer.parseInt(hostPort[1]) :
//                80;
//
//            if (start >= 0) {
//                serverHttpReq.requestURI().set(origURI.substring(start));
//            } else {
//                serverHttpReq.requestURI().set("/");
//            }
//        } else {
            // Adjust the host header.
            CBuffer hostHdr =
                serverHttpReq.getMimeHeaders().getHeader("host");
            if (hostHdr != null) {
                hostHdr.recycle();
                CBuffer cb = hostHdr;
                cb.append(dstHost);
                if (dstPort != 80) {
                    cb.append(':');
                    cb.appendInt(dstPort);
                }
            }
//        }
        if (debug) {
            HttpChannel server = serverHttpReq.getHttpChannel();
View Full Code Here

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


    static void copyHeaders(MultiMap mimeHeaders, MultiMap dest)
            throws IOException {
        for (int i = 0; i < mimeHeaders.size(); i++) {
            CBuffer name = mimeHeaders.getName(i);
            CBuffer val = dest.addValue(name.toString());
            val.set(mimeHeaders.getValue(i));
        }
    }
View Full Code Here

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

    public void testMapper() throws Exception {
        BaseMapper mapper = new BaseMapper();

        MappingData mappingData = new MappingData();
        CBuffer host = CBuffer.newInstance();
        host.set("test1.com");

        CBuffer uri = CBuffer.newInstance();
        uri.set("/foo/bar/blah/bobou/foo");

        String[] welcomes = new String[2];
        welcomes[0] = "index.html";
        welcomes[1] = "foo.html";
View Full Code Here

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

                "  456 \n" +
                "Connection:   Close\n\n");
        net.getIn().close();

        MultiMap headers = http.getRequest().getMimeHeaders();
        CBuffer cookie = headers.getHeader("Cookie");
        CBuffer conn = headers.getHeader("Connection");
        assertEquals(conn.toString(), "close");
        assertEquals(cookie.toString(), "1234 456");

        assertEquals(http.conn.headRecvBuf.toString(),
                "GET / HTTP/1.0\n" +
                "Cookie: 1234 456   \n" + // \n -> trailing space
View Full Code Here

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

        mapper.addContext("asdf.com", "", "context0", new String[0], null, null);

        MappingData mappingData = new MappingData();

        CBuffer host = CBuffer.newInstance();
        host.set("test1.com");

        CBuffer uri = CBuffer.newInstance();
        uri.set("/foo/bar/blah/bobou/foo");

        mapper.map(host, uri, mappingData);

        assertEquals("context2", mappingData.context.toString());
        assertEquals("/foo/bar", mappingData.contextPath.toString());
View Full Code Here

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

    private void processExpectation(HttpChannel http) throws IOException {
        http.expectation = false;
        MultiMap headers = http.getRequest().getMimeHeaders();

        CBuffer expect = headers.getHeader("expect");
        if ((expect != null)
                && (expect.indexOf("100-continue") != -1)) {
            http.expectation = true;

            // TODO: configure, use the callback or the servlet 'read'.
            net.getOut().append("HTTP/1.1 100 Continue\r\n\r\n");
            net.startSending();
View Full Code Here

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

        if (http.getRequest().getMimeHeaders().getHeader("Host") == null) {
            String target = http.getTarget();
            if (target == null) {
                throw new IOException("Missing host header");
            }
            CBuffer hostH = http.getRequest().getMimeHeaders().addValue("Host");
            if (target.endsWith(":80")) {
                hostH.set(target.substring(0, target.length() - 3));
            } else {
                hostH.set(target);
            }
        }

        processContentDelimitation(sendBodyState,
                http.getRequest());


        CBuffer method = http.getRequest().method();
        if (method.equals("GET") || method.equals("HEAD")) {
            // TODO: add the others
            sendBodyState.noBody = true;
        }

        // 1.0: The presence of an entity body in a request is signaled by
View Full Code Here

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

        }

        // TODO: also need to remove headers matching connection
        // ( like 'upgrade')

        CBuffer value = headers.getHeader(CONNECTION);
        // TODO: split it by space
        if (value != null) {
            value.toLower();
            if (value.indexOf(CLOSE) >= 0) {
                // 1.1 ( but we accept it for 1.0 too )
                closeStreamOnEnd("connection close");
            }
            if (http10 && value.indexOf(KEEPALIVE_S) < 0) {
                // Keep-Alive required for http/1.0
                closeStreamOnEnd("connection != keep alive");
            }
            // we have connection: keepalive, good
        } else {
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.