comparison src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 1064:a0abb16cf6e7

remove JBuffer.readFrom()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 09 Nov 2016 03:09:37 -0700
parents 957f758dcffc
children 158d1e6ac17f
comparison
equal deleted inserted replaced
1063:0157e92670f5 1064:a0abb16cf6e7
20 20
21 import java.io.IOException; 21 import java.io.IOException;
22 import java.io.InputStream; 22 import java.io.InputStream;
23 import java.io.PrintWriter; 23 import java.io.PrintWriter;
24 import java.io.Writer; 24 import java.io.Writer;
25 import java.nio.ByteBuffer;
26 import java.nio.channels.Channels;
27 import java.nio.channels.ReadableByteChannel;
25 28
26 import javax.servlet.ServletInputStream; 29 import javax.servlet.ServletInputStream;
27 import javax.servlet.ServletOutputStream; 30 import javax.servlet.ServletOutputStream;
28 import javax.servlet.http.HttpServletRequest; 31 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse; 32 import javax.servlet.http.HttpServletResponse;
831 if (_generator.isWritten()) 834 if (_generator.isWritten())
832 throw new IllegalStateException("!empty"); 835 throw new IllegalStateException("!empty");
833 836
834 try 837 try
835 { 838 {
836 int max = _generator.prepareUncheckedAddContent(); 839 ReadableByteChannel chan = Channels.newChannel(in);
837 JBuffer buffer = _generator.getUncheckedBuffer(); 840 JBuffer buffer = _generator.getUncheckedBuffer();
838 841 ByteBuffer dup = buffer.getByteBuffer().duplicate();
839 int len = buffer.readFrom(in,max); 842 dup.limit(dup.capacity());
840 843
841 while (len>=0) 844 while (true)
842 { 845 {
846 _generator.prepareUncheckedAddContent();
847
848 dup.position(buffer.limit());
849 int n = chan.read(dup);
850 if( n == -1 )
851 break;
852 buffer.limit(dup.position());
853
843 _generator.completeUncheckedAddContent(); 854 _generator.completeUncheckedAddContent();
844 _out.flush(); 855 _out.flush();
845 856 }
846 max = _generator.prepareUncheckedAddContent(); 857 /*
847 buffer = _generator.getUncheckedBuffer();
848 len = buffer.readFrom(in,max);
849 }
850 _generator.completeUncheckedAddContent(); 858 _generator.completeUncheckedAddContent();
851 _out.flush(); 859 _out.flush();
860 */
852 } 861 }
853 finally 862 finally
854 { 863 {
855 in.close(); 864 in.close();
856 } 865 }
857 } 866 }
858 } 867 }
859
860 868
861 private final class HttpInput extends ServletInputStream 869 private final class HttpInput extends ServletInputStream
862 { 870 {
863 /* ------------------------------------------------------------ */ 871 /* ------------------------------------------------------------ */
864 /* 872 /*