diff src/org/eclipse/jetty/http/HttpParser.java @ 1046:a8c92b0a08ed

add JBuffer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 22:39:39 -0700
parents dd71a59fcf72
children 2b769da7f67d
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpParser.java	Sun Nov 06 14:54:43 2016 -0700
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Mon Nov 07 22:39:39 2016 -0700
@@ -21,7 +21,6 @@
 import java.io.IOException;
 
 import org.eclipse.jetty.io.Buffer;
-import org.eclipse.jetty.io.ByteArrayBuffer;
 import org.eclipse.jetty.io.BufferUtil;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.io.EofException;
@@ -68,7 +67,7 @@
 	private int _responseStatus; // If >0 then we are parsing a response
 	private boolean _persistent;
 
-	private Buffer _contentView = new ByteArrayBuffer(0); // View of the content in the buffer for {@link Input}
+	private Buffer _contentView = BufferUtil.EMPTY_BUFFER; // View of the content in the buffer for {@link Input}
 	private int _state = STATE_START;
 	private byte _eol;
 	private int _length;
@@ -189,10 +188,11 @@
 	{
 		try
 		{
-			int progress=0;
+			int progress = 0;
 
-			if (_state == STATE_END)
+			if (_state == STATE_END) {
 				return 0;
+			}
 
 			if (_buffer==null)
 				_buffer = _header;
@@ -200,7 +200,7 @@
 
 			if (_state == STATE_CONTENT && _contentPosition == _contentLength)
 			{
-				_state=STATE_END;
+				_state = STATE_END;
 				_handler.messageComplete(_contentPosition);
 				return 1;
 			}
@@ -210,11 +210,11 @@
 			// Fill buffer if we can
 			if (length == 0)
 			{
-				int filled=-1;
-				IOException ex=null;
+				int filled = -1;
+				IOException ex = null;
 				try
 				{
-					filled=fill();
+					filled = fill();
 					LOG.debug("filled {}/{}",filled,_buffer.remaining());
 				}
 				catch(IOException e)
@@ -246,16 +246,16 @@
 					{
 						case STATE_END:
 						case STATE_SEEKING_EOF:
-							_state=STATE_END;
+							_state = STATE_END;
 							break;
 
 						case STATE_EOF_CONTENT:
-							_state=STATE_END;
+							_state = STATE_END;
 							_handler.messageComplete(_contentPosition);
 							break;
 
 						default:
-							_state=STATE_END;
+							_state = STATE_END;
 							if (!_headResponse)
 								_handler.earlyEOF();
 							_handler.messageComplete(_contentPosition);
@@ -269,23 +269,23 @@
 
 					return -1;
 				}
-				length=_buffer.remaining();
+				length = _buffer.remaining();
 			}
 
 
 			// Handle header states
 			byte ch;
-			byte[] array=_buffer.array();
-			int last=_state;
+			byte[] array = _buffer.array();
+			int last = _state;
 			while (_state<STATE_END && length-->0)
 			{
 				if (last!=_state)
 				{
 					progress++;
-					last=_state;
+					last = _state;
 				}
 
-				ch=_buffer.get();
+				ch = _buffer.get();
 
 				if (_eol == HttpTokens.CARRIAGE_RETURN)
 				{
@@ -471,7 +471,7 @@
 												{
 													try
 													{
-														_contentLength=BufferUtil.toLong(value);
+														_contentLength = BufferUtil.toLong(value);
 													}
 													catch(NumberFormatException e)
 													{
@@ -791,7 +791,7 @@
 
 					case STATE_CONTENT:
 					{
-						long remaining=_contentLength - _contentPosition;
+						long remaining = _contentLength - _contentPosition;
 						if (remaining == 0)
 						{
 							_state = _persistent?STATE_END:STATE_SEEKING_EOF;
@@ -931,7 +931,7 @@
 					}
 				}
 
-				length=_buffer.remaining();
+				length = _buffer.remaining();
 			}
 
 			return progress;