changeset 1028:2ea54e6117c3

remove HttpParser.reset()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 00:23:04 -0600
parents 6d17a257b03f
children 4e5e9e3c25b3
files src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/BlockingHttpConnection.java
diffstat 3 files changed, 7 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
diff -r 6d17a257b03f -r 2ea54e6117c3 src/org/eclipse/jetty/http/HttpParser.java
--- a/src/org/eclipse/jetty/http/HttpParser.java	Wed Nov 02 23:58:37 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Thu Nov 03 00:23:04 2016 -0600
@@ -995,52 +995,6 @@
 		return _endp.fill(_buffer);
 	}
 
-	public void reset()
-	{
-		// reset state
-		_contentView.setGetIndex(_contentView.putIndex());
-		_state = _persistent?STATE_START:(_endp.isInputShutdown()?STATE_END:STATE_SEEKING_EOF);
-		_contentLength = HttpTokens.UNKNOWN_CONTENT;
-		_contentPosition = 0;
-		_length = 0;
-		_responseStatus = 0;
-
-		// Consume LF if CRLF
-		if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer!=null && _buffer.hasContent() && _buffer.peek() == HttpTokens.LINE_FEED)
-			_eol=_buffer.get();
-
-		if (_body!=null && _body.hasContent())
-		{
-			// There is content in the body after the end of the request.
-			// This is probably a pipelined header of the next request, so we need to
-			// copy it to the header buffer.
-			if (_header==null)
-				getHeaderBuffer();
-			else
-			{
-				_header.setMarkIndex(-1);
-				_header.compact();
-			}
-			int take=_header.space();
-			if (take>_body.length())
-				take=_body.length();
-			_body.peek(_body.getIndex(),take);
-			_body.skip(_header.put(_body.peek(_body.getIndex(),take)));
-		}
-
-		if (_header!=null)
-		{
-			_header.setMarkIndex(-1);
-			_header.compact();
-		}
-		if (_body!=null)
-			_body.setMarkIndex(-1);
-
-		_buffer=_header;
-		returnBuffers();
-	}
-
-
 	public void returnBuffers()
 	{
 		if (_body!=null && !_body.hasContent() && _body.markIndex()==-1 && _buffers!=null)
diff -r 6d17a257b03f -r 2ea54e6117c3 src/org/eclipse/jetty/server/AbstractHttpConnection.java
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Wed Nov 02 23:58:37 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Thu Nov 03 00:23:04 2016 -0600
@@ -93,7 +93,7 @@
 	private final Server _server;
 	protected final HttpURI _uri = new HttpURI();
 
-	protected final HttpParser _parser;
+	protected volatile HttpParser _parser;
 	protected final HttpFields _requestFields = new HttpFields();
 	public volatile Request _request;
 	private volatile ServletInputStream _in;
@@ -119,13 +119,17 @@
 	{
 		super(endpoint);
 		_connector = connector;
-		_parser = new HttpParser(_connector.getRequestBuffers(), endpoint, new RequestHandler());
 		_generator = new HttpGenerator(_connector.getResponseBuffers(), endpoint);
 		_server = connector.server;
 		init();
 	}
 
+	void initParser() {
+		_parser = new HttpParser(_connector.getRequestBuffers(), _endp, new RequestHandler());
+	}
+
 	private void init() {
+		initParser();
 		_request = new Request(this);
 		_response = new Response(this);
 	}
@@ -225,7 +229,6 @@
 
 	protected void reset()
 	{
-		_parser.reset();
 		_requestFields.clear();
 		_generator.reset();
 		_generator.returnBuffers();// TODO maybe only on unhandle
diff -r 6d17a257b03f -r 2ea54e6117c3 src/org/eclipse/jetty/server/BlockingHttpConnection.java
--- a/src/org/eclipse/jetty/server/BlockingHttpConnection.java	Wed Nov 02 23:58:37 2016 -0600
+++ b/src/org/eclipse/jetty/server/BlockingHttpConnection.java	Thu Nov 03 00:23:04 2016 -0600
@@ -75,7 +75,7 @@
 						LOG.debug("",e);
 					}
 					_generator.sendError(e.getStatus(), e.getReason(), null, true);
-					_parser.reset();
+					initParser();
 					_endp.shutdownOutput();
 				}
 				finally