Package com.volantis.vdp.scs.util

Examples of com.volantis.vdp.scs.util.ResponseHeader


    /**
     * Receives the response from the server. The method is processed in separate thread
     */
    public void run() {
        try {
            ResponseHeader response;
            boolean run = true;

            while(!this.isInterrupted()) {
                String headerBuffer = "";
                String line = "";

                while( dataIn.available() == 0 ) {
                    if(System.currentTimeMillis() -
                            lastTime > keepalive ) {
                        clientBroker.close();
                        run = false;
                        break;
                    }
                    Thread.sleep(100);
                }
                if( !run ) break;

                while((line = readLine()).length() > 0) {
                    headerBuffer += line + ConstData.EMPTY_LINE;
                }
                response = new ResponseHeader(headerBuffer);
                clientBroker.send(response.getBytes());

                if(response.getContentLength() > 0) {
                    readBytes(response.getContentLength(), null);
                } else if(response.getTransfEncoding().
                    equalsIgnoreCase("chunked")) {
                    int numberBytes = 0;

                    while((line = readLine()).length() ==0 ) {}

                    while(!((numberBytes =
                            Integer.parseInt(line, 16)) == 0)) {
                        readBytes(numberBytes, line);
                        while((line = readLine()).length() ==0 ) {}
                    }
                }

                String connection = response.getConnection();
                if(connection.equalsIgnoreCase("close")) {
                    clientBroker.close();
                } else if(connection.equalsIgnoreCase("keep-alive")) {
                    this.keepalive = response.getKeepAliveTimeout();
                    this.lastTime = System.currentTimeMillis();
                    socket.setKeepAlive(true);
                    clientBroker.setKeepAlive(true);
                }
            }
View Full Code Here

TOP

Related Classes of com.volantis.vdp.scs.util.ResponseHeader

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.