diff 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
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Wed Nov 09 02:08:33 2016 -0700
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Wed Nov 09 03:09:37 2016 -0700
@@ -22,6 +22,9 @@
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Writer;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
 
 import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;
@@ -833,22 +836,28 @@
 
 			try
 			{
-				int max = _generator.prepareUncheckedAddContent();
+				ReadableByteChannel chan = Channels.newChannel(in);
 				JBuffer buffer = _generator.getUncheckedBuffer();
+				ByteBuffer dup = buffer.getByteBuffer().duplicate();
+				dup.limit(dup.capacity());
 
-				int len = buffer.readFrom(in,max);
+				while (true)
+				{
+					_generator.prepareUncheckedAddContent();
 
-				while (len>=0)
-				{
+					dup.position(buffer.limit());
+					int n = chan.read(dup);
+					if( n == -1 )
+						break;
+					buffer.limit(dup.position());
+
 					_generator.completeUncheckedAddContent();
 					_out.flush();
-
-					max = _generator.prepareUncheckedAddContent();
-					buffer = _generator.getUncheckedBuffer();
-					len = buffer.readFrom(in,max);
 				}
+/*
 				_generator.completeUncheckedAddContent();
 				_out.flush();
+*/
 			}
 			finally
 			{
@@ -857,7 +866,6 @@
 		}
 	}
 
-
 	private final class HttpInput extends ServletInputStream
 	{
 		/* ------------------------------------------------------------ */