diff src/org/eclipse/jetty/http/HttpParser.java @ 1051:1ab2dd0a7db5

remove JBuffer.get(int)
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 08 Nov 2016 00:18:45 -0700
parents 5ef954fad97b
children 4a2489f1d5fe
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpParser.java	Mon Nov 07 23:49:41 2016 -0700
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Tue Nov 08 00:18:45 2016 -0700
@@ -114,6 +114,15 @@
 		}
 	}
 
+	public JBuffer getBuffer(int length) {
+		JBuffer dup = _buffer.duplicate();
+		int end = _buffer.position() + length;
+		dup.limit(end);
+		_buffer.position(end);
+		return dup;
+	}
+
+
 	public long getContentLength()
 	{
 		return _contentLength;
@@ -236,7 +245,7 @@
 					{
 						if (_buffer.remaining()>0 && !_headResponse)
 						{
-							JBuffer chunk = _buffer.get(_buffer.remaining());
+							JBuffer chunk = getBuffer(_buffer.remaining());
 							_contentPosition += chunk.remaining();
 							_contentView = chunk;
 							_handler.content(); // May recurse here
@@ -783,7 +792,7 @@
 				{
 					case STATE_EOF_CONTENT:
 					{
-						JBuffer chunk = _buffer.get(_buffer.remaining());
+						JBuffer chunk = getBuffer(_buffer.remaining());
 						_contentPosition += chunk.remaining();
 						_contentView = chunk;
 						_handler.content(); // May recurse here
@@ -808,7 +817,7 @@
 							length=(int)remaining;
 						}
 
-						JBuffer chunk = _buffer.get(length);
+						JBuffer chunk = getBuffer(length);
 						_contentPosition += chunk.remaining();
 						_contentView = chunk;
 						_handler.content(); // May recurse here
@@ -899,7 +908,7 @@
 						}
 						else if (length > remaining)
 							length=remaining;
-						JBuffer chunk = _buffer.get(length);
+						JBuffer chunk = getBuffer(length);
 						_contentPosition += chunk.remaining();
 						_chunkPosition += chunk.remaining();
 						_contentView = chunk;