diff src/org/eclipse/jetty/http/HttpParser.java @ 1034:563458c4dc93

remove HttpGenerator.reset()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 21:02:59 -0600
parents 4ada7a8c128a
children b87f97f6418a
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpParser.java	Thu Nov 03 04:00:25 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Thu Nov 03 21:02:59 2016 -0600
@@ -36,28 +36,26 @@
 	private static final Logger LOG = LoggerFactory.getLogger(HttpParser.class);
 
 	// States
-	private static final int STATE_START=-14;
-	private static final int STATE_FIELD0=-13;
-	private static final int STATE_SPACE1=-12;
-	private static final int STATE_STATUS=-11;
-	private static final int STATE_URI=-10;
-	private static final int STATE_SPACE2=-9;
-	private static final int STATE_END0=-8;
-	private static final int STATE_END1=-7;
-	private static final int STATE_FIELD2=-6;
-	private static final int STATE_HEADER=-5;
-	private static final int STATE_HEADER_NAME=-4;
-	private static final int STATE_HEADER_IN_NAME=-3;
-	private static final int STATE_HEADER_VALUE=-2;
-	private static final int STATE_HEADER_IN_VALUE=-1;
-	private static final int STATE_END=0;
-	private static final int STATE_EOF_CONTENT=1;
-	private static final int STATE_CONTENT=2;
-	private static final int STATE_CHUNKED_CONTENT=3;
-	private static final int STATE_CHUNK_SIZE=4;
-	private static final int STATE_CHUNK_PARAMS=5;
-	private static final int STATE_CHUNK=6;
-	private static final int STATE_SEEKING_EOF=7;
+	private static final int STATE_START = -14;
+	private static final int STATE_FIELD0 = -13;
+	private static final int STATE_SPACE1 = -12;
+	private static final int STATE_STATUS = -11;
+	private static final int STATE_URI = -10;
+	private static final int STATE_SPACE2 = -9;
+	private static final int STATE_FIELD2 = -6;
+	private static final int STATE_HEADER = -5;
+	private static final int STATE_HEADER_NAME = -4;
+	private static final int STATE_HEADER_IN_NAME = -3;
+	private static final int STATE_HEADER_VALUE = -2;
+	private static final int STATE_HEADER_IN_VALUE = -1;
+	private static final int STATE_END = 0;
+	private static final int STATE_EOF_CONTENT = 1;
+	private static final int STATE_CONTENT = 2;
+	private static final int STATE_CHUNKED_CONTENT = 3;
+	private static final int STATE_CHUNK_SIZE = 4;
+	private static final int STATE_CHUNK_PARAMS = 5;
+	private static final int STATE_CHUNK = 6;
+	private static final int STATE_SEEKING_EOF = 7;
 
 	private final EventHandler _handler;
 	private final EndPoint _endp;
@@ -132,7 +130,7 @@
 	{
 		_persistent = persistent;
 		if (!_persistent &&(_state==STATE_END || _state==STATE_START))
-			_state=STATE_SEEKING_EOF;
+			_state = STATE_SEEKING_EOF;
 	}
 
 	/* ------------------------------------------------------------------------------- */
@@ -203,7 +201,7 @@
 					progress++;
 				else if (filled < 0 )
 				{
-					_persistent=false;
+					_persistent = false;
 
 					// do we have content to deliver?
 					if (_state>STATE_END)
@@ -306,7 +304,7 @@
 							_buffer.mark();
 							if (_responseStatus>=0)
 							{
-								_state=STATE_STATUS;
+								_state = STATE_STATUS;
 								_responseStatus=ch-'0';
 							}
 							else
@@ -323,7 +321,7 @@
 						{
 //							_tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1);
 							_tok1 = _buffer.toString(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex());
-							_state=STATE_SPACE2;
+							_state = STATE_SPACE2;
 							continue;
 						}
 						else if (ch>='0' && ch<='9')
@@ -334,7 +332,7 @@
 						else if (ch < HttpTokens.SPACE && ch>=0)
 						{
 							_eol=ch;
-							_state=STATE_HEADER;
+							_state = STATE_HEADER;
 							_tok0 = "";
 							_tok1 = "";
 							_multiLineValue=null;
@@ -357,8 +355,8 @@
 						{
 							// HTTP/0.9
 							_handler.startRequest(_tok0, _buffer.sliceFromMark().toString(), null);
-							_persistent=false;
-							_state=STATE_SEEKING_EOF;
+							_persistent = false;
+							_state = STATE_SEEKING_EOF;
 							_handler.headerComplete();
 							_handler.messageComplete(_contentPosition);
 							return 1;
@@ -385,8 +383,8 @@
 							{
 								// HTTP/0.9
 								_handler.startRequest(_tok0, _tok1, null);
-								_persistent=false;
-								_state=STATE_SEEKING_EOF;
+								_persistent = false;
+								_state = STATE_SEEKING_EOF;
 								_handler.headerComplete();
 								_handler.messageComplete(_contentPosition);
 								return 1;
@@ -478,11 +476,11 @@
 												switch(HttpHeaderValues.CACHE.getOrdinal(value))
 												{
 													case HttpHeaderValues.CLOSE_ORDINAL:
-														_persistent=false;
+														_persistent = false;
 														break;
 
 													case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
-														_persistent=true;
+														_persistent = true;
 														break;
 
 													case -1: // No match, may be multi valued
@@ -492,11 +490,11 @@
 															switch(HttpHeaderValues.CACHE.getOrdinal(v.trim()))
 															{
 																case HttpHeaderValues.CLOSE_ORDINAL:
-																	_persistent=false;
+																	_persistent = false;
 																	break;
 
 																case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
-																	_persistent=true;
+																	_persistent = true;
 																	break;
 															}
 														}
@@ -555,7 +553,7 @@
 
 										case HttpTokens.NO_CONTENT:
 											_handler.headerComplete();
-											_state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
+											_state = _persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
 											_handler.messageComplete(_contentPosition);
 											return 1;
 
@@ -619,7 +617,7 @@
 								if (_length == -1)
 									_buffer.mark();
 								_length=_buffer.getIndex() - _buffer.markIndex();
-								_state=STATE_HEADER_IN_NAME;
+								_state = STATE_HEADER_IN_NAME;
 							}
 						}
 
@@ -685,7 +683,7 @@
 								if (_length == -1)
 									_buffer.mark();
 								_length=_buffer.getIndex() - _buffer.markIndex();
-								_state=STATE_HEADER_IN_VALUE;
+								_state = STATE_HEADER_IN_VALUE;
 							}
 						}
 						break;
@@ -728,7 +726,7 @@
 			// Handle HEAD response
 			if (_responseStatus>0 && _headResponse)
 			{
-				_state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
+				_state = _persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
 				_handler.messageComplete(_contentLength);
 			}
 
@@ -769,7 +767,7 @@
 						long remaining=_contentLength - _contentPosition;
 						if (remaining == 0)
 						{
-							_state=_persistent?STATE_END:STATE_SEEKING_EOF;
+							_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 							_handler.messageComplete(_contentPosition);
 							return 1;
 						}
@@ -788,7 +786,7 @@
 
 						if(_contentPosition == _contentLength)
 						{
-							_state=_persistent?STATE_END:STATE_SEEKING_EOF;
+							_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 							_handler.messageComplete(_contentPosition);
 						}
 						// TODO adjust the _buffer to keep unconsumed content
@@ -806,7 +804,7 @@
 						{
 							_chunkLength=0;
 							_chunkPosition=0;
-							_state=STATE_CHUNK_SIZE;
+							_state = STATE_CHUNK_SIZE;
 						}
 						break;
 					}
@@ -822,12 +820,12 @@
 							{
 								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
 									_eol=_buffer.get();
-								_state=_persistent?STATE_END:STATE_SEEKING_EOF;
+								_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 								_handler.messageComplete(_contentPosition);
 								return 1;
 							}
 							else
-								_state=STATE_CHUNK;
+								_state = STATE_CHUNK;
 						}
 						else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON)
 							_state=STATE_CHUNK_PARAMS;
@@ -852,7 +850,7 @@
 							{
 								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
 									_eol=_buffer.get();
-								_state=_persistent?STATE_END:STATE_SEEKING_EOF;
+								_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 								_handler.messageComplete(_contentPosition);
 								return 1;
 							}
@@ -886,7 +884,7 @@
 						// Close if there is more data than CRLF
 						if (_buffer.length()>2)
 						{
-							_state=STATE_END;
+							_state = STATE_END;
 							_endp.close();
 						}
 						else  
@@ -913,8 +911,8 @@
 		}
 		catch(HttpException e)
 		{
-			_persistent=false;
-			_state=STATE_SEEKING_EOF;
+			_persistent = false;
+			_state = STATE_SEEKING_EOF;
 			throw e;
 		}
 	}