Package org.apache.http.nio.entity

Examples of org.apache.http.nio.entity.ByteArrayNIOEntity


            if (!file.exists()) {
               
                response.setStatusCode(HttpStatus.SC_NOT_FOUND);
                byte[] msg = EncodingUtils.getAsciiBytes(
                        file.getName() + ": not found");
                ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
                entity.setContentType("text/plain; charset=US-ASCII");
                response.setEntity(entity);
               
            } else if (!file.canRead() || file.isDirectory()) {

                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
                byte[] msg = EncodingUtils.getAsciiBytes(
                        file.getName() + ": access denied");
                ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
                entity.setContentType("text/plain; charset=US-ASCII");
                response.setEntity(entity);

            } else {

                FileNIOEntity entity = new FileNIOEntity(file, "text/html");
View Full Code Here


                final HttpResponse response,
                final HttpContext context) {
            response.setStatusLine(HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST);
            byte[] msg = EncodingUtils.getAsciiBytes(
                    "Malformed HTTP request: " + ex.getMessage());
            ByteArrayNIOEntity entity = new ByteArrayNIOEntity(msg);
            entity.setContentType("text/plain; charset=US-ASCII");
            response.setEntity(entity);
        }
View Full Code Here

TOP

Related Classes of org.apache.http.nio.entity.ByteArrayNIOEntity

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.