Package org.mule.transport.http

Examples of org.mule.transport.http.ResponseWriter


        try
        {
            HttpResponse response = (HttpResponse)src;
            ByteArrayOutputStream bos = new ByteArrayOutputStream(8192);
            OutputStream outstream = bos;
            ResponseWriter writer = new ResponseWriter(outstream, encoding);
            writer.println(response.getStatusLine());
            Iterator item = response.getHeaderIterator();
            while (item.hasNext())
            {
                Header header = (Header)item.next();
                writer.print(header.toExternalForm());
            }
            writer.println();
            writer.flush();

            if (response.hasBody())
            {
                OutputHandler handler = response.getBody();
                Header transferenc = response.getFirstHeader(HttpConstants.HEADER_TRANSFER_ENCODING);
                if (transferenc != null)
                {
                    response.removeHeaders(HttpConstants.HEADER_CONTENT_LENGTH);
                    if (transferenc.getValue().indexOf(HttpConstants.TRANSFER_ENCODING_CHUNKED) != -1)
                    {
                        outstream = new ChunkedOutputStream(outstream);
                    }
                }

                handler.write(RequestContext.getEvent(), outstream);

                if (outstream instanceof ChunkedOutputStream)
                {
                    ((ChunkedOutputStream)outstream).finish();
                }
            }

            outstream.flush();
            bos.flush();
            byte[] result = bos.toByteArray();
            outstream.close();
            writer.close();
            bos.close();

            String output = null;
            try
            {
View Full Code Here


        try
        {
            HttpResponse response = (HttpResponse)src;
            ByteArrayOutputStream bos = new ByteArrayOutputStream(8192);
            OutputStream outstream = bos;
            ResponseWriter writer = new ResponseWriter(outstream, encoding);
            writer.println(response.getStatusLine());
            Iterator item = response.getHeaderIterator();
            while (item.hasNext())
            {
                Header header = (Header)item.next();
                writer.print(header.toExternalForm());
            }
            writer.println();
            writer.flush();

            if (response.hasBody())
            {
                OutputHandler handler = response.getBody();
                Header transferenc = response.getFirstHeader(HttpConstants.HEADER_TRANSFER_ENCODING);
                if (transferenc != null)
                {
                    response.removeHeaders(HttpConstants.HEADER_CONTENT_LENGTH);
                    if (transferenc.getValue().indexOf(HttpConstants.TRANSFER_ENCODING_CHUNKED) != -1)
                    {
                        outstream = new ChunkedOutputStream(outstream);
                    }
                }

                handler.write(RequestContext.getEvent(), outstream);

                if (outstream instanceof ChunkedOutputStream)
                {
                    ((ChunkedOutputStream)outstream).finish();
                }
            }

            outstream.flush();
            bos.flush();
            byte[] result = bos.toByteArray();
            outstream.close();
            writer.close();
            bos.close();

            String output = null;
            try
            {
View Full Code Here

TOP

Related Classes of org.mule.transport.http.ResponseWriter

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.