changeset 999:74b9daf2826c

simplify Response
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 19 Oct 2016 00:59:46 -0600
parents bf176925e00f
children 32d4b569567c
files src/org/eclipse/jetty/http/HttpHeaderValues.java src/org/eclipse/jetty/io/BufferCache.java src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/Response.java
diffstat 4 files changed, 136 insertions(+), 364 deletions(-) [+]
line wrap: on
line diff
diff -r bf176925e00f -r 74b9daf2826c src/org/eclipse/jetty/http/HttpHeaderValues.java
--- a/src/org/eclipse/jetty/http/HttpHeaderValues.java	Tue Oct 18 23:01:00 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpHeaderValues.java	Wed Oct 19 00:59:46 2016 -0600
@@ -32,57 +32,57 @@
  */
 public class HttpHeaderValues extends BufferCache
 {
-    public final static String
-        CLOSE="close",
-        CHUNKED="chunked",
-        GZIP="gzip",
-        IDENTITY="identity",
-        KEEP_ALIVE="keep-alive",
-        CONTINUE="100-continue",
-        PROCESSING="102-processing",
-        TE="TE",
-        BYTES="bytes",
-        NO_CACHE="no-cache",
-        UPGRADE="Upgrade";
+	public final static String
+		CLOSE="close",
+		CHUNKED="chunked",
+		GZIP="gzip",
+		IDENTITY="identity",
+		KEEP_ALIVE="keep-alive",
+		CONTINUE="100-continue",
+		PROCESSING="102-processing",
+		TE="TE",
+		BYTES="bytes",
+		NO_CACHE="no-cache",
+		UPGRADE="Upgrade";
 
-    public final static int
-        CLOSE_ORDINAL=1,
-        CHUNKED_ORDINAL=2,
-        GZIP_ORDINAL=3,
-        IDENTITY_ORDINAL=4,
-        KEEP_ALIVE_ORDINAL=5,
-        CONTINUE_ORDINAL=6,
-        PROCESSING_ORDINAL=7,
-        TE_ORDINAL=8,
-        BYTES_ORDINAL=9,
-        NO_CACHE_ORDINAL=10,
-        UPGRADE_ORDINAL=11;
-    
-    public final static HttpHeaderValues CACHE= new HttpHeaderValues();
+	public final static int
+		CLOSE_ORDINAL=1,
+		CHUNKED_ORDINAL=2,
+		GZIP_ORDINAL=3,
+		IDENTITY_ORDINAL=4,
+		KEEP_ALIVE_ORDINAL=5,
+		CONTINUE_ORDINAL=6,
+		PROCESSING_ORDINAL=7,
+		TE_ORDINAL=8,
+		BYTES_ORDINAL=9,
+		NO_CACHE_ORDINAL=10,
+		UPGRADE_ORDINAL=11;
+	
+	public final static HttpHeaderValues CACHE = new HttpHeaderValues();
 
-    public final static Buffer 
-        CLOSE_BUFFER=CACHE.add(CLOSE,CLOSE_ORDINAL),
-        CHUNKED_BUFFER=CACHE.add(CHUNKED,CHUNKED_ORDINAL),
-        GZIP_BUFFER=CACHE.add(GZIP,GZIP_ORDINAL),
-        IDENTITY_BUFFER=CACHE.add(IDENTITY,IDENTITY_ORDINAL),
-        KEEP_ALIVE_BUFFER=CACHE.add(KEEP_ALIVE,KEEP_ALIVE_ORDINAL),
-        CONTINUE_BUFFER=CACHE.add(CONTINUE, CONTINUE_ORDINAL),
-        PROCESSING_BUFFER=CACHE.add(PROCESSING, PROCESSING_ORDINAL),
-        TE_BUFFER=CACHE.add(TE,TE_ORDINAL),
-        BYTES_BUFFER=CACHE.add(BYTES,BYTES_ORDINAL),
-        NO_CACHE_BUFFER=CACHE.add(NO_CACHE,NO_CACHE_ORDINAL),
-        UPGRADE_BUFFER=CACHE.add(UPGRADE,UPGRADE_ORDINAL);
-        
+	public final static Buffer 
+		CLOSE_BUFFER=CACHE.add(CLOSE,CLOSE_ORDINAL),
+		CHUNKED_BUFFER=CACHE.add(CHUNKED,CHUNKED_ORDINAL),
+		GZIP_BUFFER=CACHE.add(GZIP,GZIP_ORDINAL),
+		IDENTITY_BUFFER=CACHE.add(IDENTITY,IDENTITY_ORDINAL),
+		KEEP_ALIVE_BUFFER=CACHE.add(KEEP_ALIVE,KEEP_ALIVE_ORDINAL),
+		CONTINUE_BUFFER=CACHE.add(CONTINUE, CONTINUE_ORDINAL),
+		PROCESSING_BUFFER=CACHE.add(PROCESSING, PROCESSING_ORDINAL),
+		TE_BUFFER=CACHE.add(TE,TE_ORDINAL),
+		BYTES_BUFFER=CACHE.add(BYTES,BYTES_ORDINAL),
+		NO_CACHE_BUFFER=CACHE.add(NO_CACHE,NO_CACHE_ORDINAL),
+		UPGRADE_BUFFER=CACHE.add(UPGRADE,UPGRADE_ORDINAL);
+		
 
-    public static boolean hasKnownValues(int httpHeaderOrdinal)
-    {
-        switch(httpHeaderOrdinal)
-        {
-            case HttpHeaders.CONNECTION_ORDINAL:
-            case HttpHeaders.TRANSFER_ENCODING_ORDINAL:
-            case HttpHeaders.CONTENT_ENCODING_ORDINAL:
-                return true;
-        }
-        return false;
-    }
+	public static boolean hasKnownValues(int httpHeaderOrdinal)
+	{
+		switch(httpHeaderOrdinal)
+		{
+			case HttpHeaders.CONNECTION_ORDINAL:
+			case HttpHeaders.TRANSFER_ENCODING_ORDINAL:
+			case HttpHeaders.CONTENT_ENCODING_ORDINAL:
+				return true;
+		}
+		return false;
+	}
 }
diff -r bf176925e00f -r 74b9daf2826c src/org/eclipse/jetty/io/BufferCache.java
--- a/src/org/eclipse/jetty/io/BufferCache.java	Tue Oct 18 23:01:00 2016 -0600
+++ b/src/org/eclipse/jetty/io/BufferCache.java	Wed Oct 19 00:59:46 2016 -0600
@@ -32,9 +32,9 @@
  */
 public class BufferCache
 {
-	private final HashMap _bufferMap=new HashMap();
+	private final HashMap _bufferMap = new HashMap();
 	private final TreeMap _stringMap = new TreeMap();
-	private final ArrayList _index= new ArrayList();
+	private final ArrayList _index = new ArrayList();
 
 	/* ------------------------------------------------------------------------------- */
 	/** Add a buffer to the cache at the specified index.
diff -r bf176925e00f -r 74b9daf2826c src/org/eclipse/jetty/server/AbstractHttpConnection.java
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Tue Oct 18 23:01:00 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Wed Oct 19 00:59:46 2016 -0600
@@ -115,7 +115,6 @@
 	private String _charset;
 	private boolean _expect = false;
 	private boolean _expect100Continue = false;
-	private boolean _expect102Processing = false;
 	private boolean _head = false;
 	private boolean _host = false;
 	private boolean _delayedHandling = false;
@@ -432,11 +431,6 @@
 		}
 	}
 
-	public final boolean isExpecting102Processing()
-	{
-		return _expect102Processing;
-	}
-
 	public final int getMaxIdleTime()
 	{
 		if (_connector.server.isLowOnThreads() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime())
@@ -463,7 +457,6 @@
 		_host = false;
 		_expect = false;
 		_expect100Continue = false;
-		_expect102Processing=false;
 		_delayedHandling=false;
 		_charset=null;
 
@@ -535,10 +528,6 @@
 							_expect100Continue = true;
 							break;
 
-						case HttpHeaderValues.PROCESSING_ORDINAL:
-							_expect102Processing = true;
-							break;
-
 						default:
 							String[] values = value.toString().split(",");
 							for  (int i=0;values!=null && i<values.length;i++)
@@ -553,9 +542,6 @@
 										case HttpHeaderValues.CONTINUE_ORDINAL:
 											_expect100Continue = true;
 											break;
-										case HttpHeaderValues.PROCESSING_ORDINAL:
-											_expect102Processing = true;
-											break;
 										default:
 											_expect = true;
 									}
diff -r bf176925e00f -r 74b9daf2826c src/org/eclipse/jetty/server/Response.java
--- a/src/org/eclipse/jetty/server/Response.java	Tue Oct 18 23:01:00 2016 -0600
+++ b/src/org/eclipse/jetty/server/Response.java	Wed Oct 19 00:59:46 2016 -0600
@@ -57,7 +57,7 @@
  * Implements {@link javax.servlet.http.HttpServletResponse} from the <code>javax.servlet.http</code> package.
  * </p>
  */
-public class Response implements HttpServletResponse
+public final class Response implements HttpServletResponse
 {
 	private static final Logger LOG = LoggerFactory.getLogger(Response.class);
 
@@ -81,7 +81,7 @@
 	public final static String HTTP_ONLY_COMMENT="__HTTP_ONLY__";
 	
 	private final AbstractHttpConnection _connection;
-	private int _status=SC_OK;
+	private int _status = SC_OK;
 	private String _reason;
 	private Locale _locale;
 	private String _mimeType;
@@ -92,47 +92,32 @@
 	private volatile int _outputState;
 	private PrintWriter _writer;
 
-	/* ------------------------------------------------------------ */
-	/**
-	 *
-	 */
 	public Response(AbstractHttpConnection connection)
 	{
-		_connection=connection;
+		_connection = connection;
 	}
 
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#reset()
-	 */
-	protected void recycle()
+	void recycle()
 	{
-		_status=SC_OK;
-		_reason=null;
-		_locale=null;
-		_mimeType=null;
-		_cachedMimeType=null;
-		_characterEncoding=null;
-		_explicitEncoding=false;
-		_contentType=null;
-		_writer=null;
-		_outputState=NONE;
+		_status = SC_OK;
+		_reason = null;
+		_locale = null;
+		_mimeType = null;
+		_cachedMimeType = null;
+		_characterEncoding = null;
+		_explicitEncoding = false;
+		_contentType = null;
+		_writer = null;
+		_outputState = NONE;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
-	 */
 	public void addCookie(HttpCookie cookie)
 	{
 		_connection._responseFields.addSetCookie(cookie);
 	}
 	
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
-	 */
+	@Override
 	public void addCookie(Cookie cookie)
 	{
 		String comment=cookie.getComment();
@@ -160,65 +145,53 @@
 				cookie.getVersion());
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
-	 */
+	@Override
 	public boolean containsHeader(String name)
 	{
 		return _connection._responseFields.containsKey(name);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
-	 */
+	@Override
 	public String encodeURL(String url)
 	{
 		throw new UnsupportedOperationException();
 	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String)
-	 */
+	@Override
 	public String encodeRedirectURL(String url)
 	{
-		return encodeURL(url);
+		throw new UnsupportedOperationException();
 	}
 
-	/* ------------------------------------------------------------ */
+	@Override
 	@Deprecated
 	public String encodeUrl(String url)
 	{
-		return encodeURL(url);
+		throw new UnsupportedOperationException();
 	}
 
-	/* ------------------------------------------------------------ */
+	@Override
 	@Deprecated
 	public String encodeRedirectUrl(String url)
 	{
-		return encodeRedirectURL(url);
+		throw new UnsupportedOperationException();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String)
-	 */
+	@Override
 	public void sendError(int code, String message) throws IOException
 	{
 		if (isCommitted())
 			LOG.warn("Committed before "+code+" "+message);
 
 		resetBuffer();
-		_characterEncoding=null;
+		_characterEncoding = null;
 		setHeader(HttpHeaders.EXPIRES,null);
 		setHeader(HttpHeaders.LAST_MODIFIED,null);
 		setHeader(HttpHeaders.CACHE_CONTROL,null);
 		setHeader(HttpHeaders.CONTENT_TYPE,null);
 		setHeader(HttpHeaders.CONTENT_LENGTH,null);
 
-		_outputState=NONE;
+		_outputState = NONE;
 		setStatus(code,message);
 
 		if (message==null)
@@ -278,44 +251,21 @@
 		{
 			_connection._requestFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
 			_connection._requestFields.remove(HttpHeaders.CONTENT_LENGTH_BUFFER);
-			_characterEncoding=null;
-			_mimeType=null;
-			_cachedMimeType=null;
+			_characterEncoding = null;
+			_mimeType = null;
+			_cachedMimeType = null;
 		}
 
 		complete();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#sendError(int)
-	 */
+	@Override
 	public void sendError(int sc) throws IOException
 	{
-		if (sc==102)
-			sendProcessing();
-		else
-			sendError(sc,null);
+		sendError(sc,null);
 	}
 
-	/* ------------------------------------------------------------ */
-	/* Send a 102-Processing response.
-	 * If the connection is a HTTP connection, the version is 1.1 and the
-	 * request has a Expect header starting with 102, then a 102 response is
-	 * sent. This indicates that the request still be processed and real response
-	 * can still be sent.   This method is called by sendError if it is passed 102.
-	 * @see javax.servlet.http.HttpServletResponse#sendError(int)
-	 */
-	public void sendProcessing() throws IOException
-	{
-		if (_connection.isExpecting102Processing() && !isCommitted())
-			_connection._generator.send1xx(HttpStatus.PROCESSING_102);
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
-	 */
+	@Override
 	public void sendRedirect(String location) throws IOException
 	{
 		if (location==null)
@@ -377,28 +327,19 @@
 
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, long)
-	 */
+	@Override
 	public void setDateHeader(String name, long date)
 	{
 		_connection._responseFields.putDateField(name, date);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, long)
-	 */
+	@Override
 	public void addDateHeader(String name, long date)
 	{
 		_connection._responseFields.addDateField(name, date);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
-	 */
+	@Override
 	public void setHeader(String name, String value)
 	{
 		if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name))
@@ -417,24 +358,20 @@
 	}
 
 
-	/* ------------------------------------------------------------ */
+	@Override
 	public Collection<String> getHeaderNames()
 	{
 		final HttpFields fields=_connection._responseFields;
 		return fields.getFieldNamesCollection();
 	}
 	
-	/* ------------------------------------------------------------ */
-	/*
-	 */
+	@Override
 	public String getHeader(String name)
 	{
 		return _connection._responseFields.getStringField(name);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 */
+	@Override
 	public Collection<String> getHeaders(String name)
 	{
 		final HttpFields fields=_connection._responseFields;
@@ -444,10 +381,7 @@
 		return i;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
-	 */
+	@Override
 	public void addHeader(String name, String value)
 	{
 
@@ -462,10 +396,7 @@
 			_connection._generator.setContentLength(Long.parseLong(value));
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, int)
-	 */
+	@Override
 	public void setIntHeader(String name, int value)
 	{
 		_connection._responseFields.putLongField(name, value);
@@ -473,10 +404,7 @@
 			_connection._generator.setContentLength(value);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, int)
-	 */
+	@Override
 	public void addIntHeader(String name, int value)
 	{
 		_connection._responseFields.addLongField(name, value);
@@ -484,83 +412,47 @@
 			_connection._generator.setContentLength(value);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#setStatus(int)
-	 */
+	@Override
 	public void setStatus(int sc)
 	{
 		setStatus(sc,null);
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.http.HttpServletResponse#setStatus(int, java.lang.String)
-	 */
+	@Override
 	public void setStatus(int sc, String sm)
 	{
 		if (sc<=0)
 			throw new IllegalArgumentException();
-		_status=sc;
-		_reason=sm;
+		_status = sc;
+		_reason = sm;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getCharacterEncoding()
-	 */
+	@Override
 	public String getCharacterEncoding()
 	{
 		if (_characterEncoding==null)
-			_characterEncoding=StringUtil.__ISO_8859_1;
+			_characterEncoding = StringUtil.__ISO_8859_1;
 		return _characterEncoding;
 	}
 	
-	/* ------------------------------------------------------------ */
-	String getSetCharacterEncoding()
-	{
-		return _characterEncoding;
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getContentType()
-	 */
+	@Override
 	public String getContentType()
 	{
 		return _contentType;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getOutputStream()
-	 */
+	@Override
 	public ServletOutputStream getOutputStream() throws IOException
 	{
 		if (_outputState!=NONE && _outputState!=STREAM)
 			throw new IllegalStateException("WRITER");
 
 		ServletOutputStream out = _connection.getOutputStream();
-		_outputState=STREAM;
+		_outputState = STREAM;
 		return out;
 	}
 
-	/* ------------------------------------------------------------ */
-	public boolean isWriting()
-	{
-		return _outputState==WRITER;
-	}
-
-	/* ------------------------------------------------------------ */
-	public boolean isOutputing()
-	{
-		return _outputState!=NONE;
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getWriter()
-	 */
+	@Override
 	public PrintWriter getWriter() throws IOException
 	{
 		if (_outputState!=NONE && _outputState!=WRITER)
@@ -591,15 +483,12 @@
 		return _writer;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
-	 */
+	@Override
 	public void setCharacterEncoding(String encoding)
 	{
 		if (this._outputState==0 && !isCommitted())
 		{
-			_explicitEncoding=true;
+			_explicitEncoding = true;
 
 			if (encoding==null)
 			{
@@ -608,11 +497,11 @@
 				{
 					_characterEncoding=null;
 					if (_cachedMimeType!=null)
-						_contentType=_cachedMimeType.toString();
+						_contentType = _cachedMimeType.toString();
 					else if (_mimeType!=null)
-						_contentType=_mimeType;
+						_contentType = _mimeType;
 					else
-						_contentType=null;
+						_contentType = null;
 
 					if (_contentType==null)
 						_connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
@@ -635,7 +524,7 @@
 							CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding);
 							if (content_type!=null)
 							{
-								_contentType=content_type.toString();
+								_contentType = content_type.toString();
 								_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type);
 							}
 						}
@@ -669,10 +558,7 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setContentLength(int)
-	 */
+	@Override
 	public void setContentLength(int len)
 	{
 		// Protect from setting after committed as default handling
@@ -703,25 +589,7 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setContentLength(int)
-	 */
-	public void setLongContentLength(long len)
-	{
-		// Protect from setting after committed as default handling
-		// of a servlet HEAD request ALWAYS sets _content length, even
-		// if the getHandling committed the response!
-		if (isCommitted())
-			return;
-		_connection._generator.setContentLength(len);
-		_connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len);
-	}
-
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
-	 */
+	@Override
 	public void setContentType(String contentType)
 	{
 		if (isCommitted())
@@ -734,9 +602,9 @@
 		if (contentType==null)
 		{
 			if (_locale==null)
-				_characterEncoding=null;
-			_mimeType=null;
-			_cachedMimeType=null;
+				_characterEncoding = null;
+			_mimeType = null;
+			_cachedMimeType = null;
 			_contentType=null;
 			_connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER);
 		}
@@ -750,14 +618,14 @@
 				// we have content type parameters
 
 				// Extract params off mimetype
-				_mimeType=contentType.substring(0,i0).trim();
-				_cachedMimeType=MimeTypes.CACHE.get(_mimeType);
+				_mimeType = contentType.substring(0,i0).trim();
+				_cachedMimeType = MimeTypes.CACHE.get(_mimeType);
 
 				// Look for charset
 				int i1=contentType.indexOf("charset=",i0+1);
 				if (i1>=0)
 				{
-					_explicitEncoding=true;
+					_explicitEncoding = true;
 					int i8=i1+8;
 					int i2 = contentType.indexOf(' ',i8);
 
@@ -776,13 +644,13 @@
 								}
 								else
 								{
-									_contentType=_mimeType+";charset="+_characterEncoding;
+									_contentType = _mimeType+";charset="+_characterEncoding;
 									_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
 								}
 							}
 							else
 							{
-								_contentType=_mimeType+";charset="+_characterEncoding;
+								_contentType = _mimeType+";charset="+_characterEncoding;
 								_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
 							}
 						}
@@ -800,7 +668,7 @@
 					else if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' '))
 					{
 						// The params are just the char encoding
-						_cachedMimeType=MimeTypes.CACHE.get(_mimeType);
+						_cachedMimeType = MimeTypes.CACHE.get(_mimeType);
 						_characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8));
 
 						if (_cachedMimeType!=null)
@@ -838,15 +706,15 @@
 				}
 				else // No encoding in the params.
 				{
-					_cachedMimeType=null;
+					_cachedMimeType = null;
 					_contentType=_characterEncoding==null?contentType:contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
 					_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
 				}
 			}
 			else // No params at all
 			{
-				_mimeType=contentType;
-				_cachedMimeType=MimeTypes.CACHE.get(_mimeType);
+				_mimeType = contentType;
+				_cachedMimeType = MimeTypes.CACHE.get(_mimeType);
 
 				if (_characterEncoding!=null)
 				{
@@ -860,7 +728,7 @@
 						}
 						else
 						{
-							_contentType=_mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
+							_contentType = _mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ");
 							_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
 						}
 					}
@@ -872,7 +740,7 @@
 				}
 				else if (_cachedMimeType!=null)
 				{
-					_contentType=_cachedMimeType.toString();
+					_contentType = _cachedMimeType.toString();
 					_connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType);
 				}
 				else
@@ -884,43 +752,31 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setBufferSize(int)
-	 */
+	@Override
 	public void setBufferSize(int size)
 	{
 		throw new UnsupportedOperationException();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getBufferSize()
-	 */
+	@Override
 	public int getBufferSize()
 	{
 		return _connection._generator.getContentBufferSize();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#flushBuffer()
-	 */
+	@Override
 	public void flushBuffer() throws IOException
 	{
 		_connection.flushResponse();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#reset()
-	 */
+	@Override
 	public void reset()
 	{
 		resetBuffer();
 		fwdReset();
-		_status=200;
-		_reason=null;
+		_status = 200;
+		_reason = null;
 		
 		HttpFields response_fields=_connection._responseFields;
 		
@@ -954,34 +810,8 @@
 		}
 	}
 	
-
-	public void reset(boolean preserveCookies)
-	{ 
-		if (!preserveCookies)
-			reset();
-		else
-		{
-			HttpFields response_fields=_connection._responseFields;
-
-			ArrayList<String> cookieValues = new ArrayList<String>(5);
-			Enumeration<String> vals = response_fields.getValues(HttpHeaders.SET_COOKIE);
-			while (vals.hasMoreElements())
-				cookieValues.add((String)vals.nextElement());
-
-			reset();
-
-			for (String v:cookieValues)
-				response_fields.add(HttpHeaders.SET_COOKIE, v);
-		}
-	}
 	
-	
-	
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#reset()
-	 */
-	public void fwdReset()
+	private void fwdReset()
 	{
 		resetBuffer();
 
@@ -989,10 +819,7 @@
 		_outputState=NONE;
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#resetBuffer()
-	 */
+	@Override
 	public void resetBuffer()
 	{
 		if (isCommitted())
@@ -1000,20 +827,14 @@
 		_connection._generator.resetBuffer();
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#isCommitted()
-	 */
+	@Override
 	public boolean isCommitted()
 	{
 		return _connection._generator.isCommitted();
 	}
 
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#setLocale(java.util.Locale)
-	 */
+	@Override
 	public void setLocale(Locale locale)
 	{
 		if (locale == null || isCommitted())
@@ -1023,10 +844,7 @@
 		_connection._responseFields.put(HttpHeaders.CONTENT_LANGUAGE_BUFFER,locale.toString().replace('_','-'));
 	}
 
-	/* ------------------------------------------------------------ */
-	/*
-	 * @see javax.servlet.ServletResponse#getLocale()
-	 */
+	@Override
 	public Locale getLocale()
 	{
 		if (_locale==null)
@@ -1054,9 +872,6 @@
 		return _reason;
 	}
 
-	/* ------------------------------------------------------------ */
-	/**
-	 */
 	public void complete()
 		throws IOException
 	{
@@ -1074,13 +889,11 @@
 		return _connection._generator.getContentWritten();
 	}
 
-	/* ------------------------------------------------------------ */
 	public HttpFields getHttpFields()
 	{
 		return _connection._responseFields;
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	public String toString()
 	{
@@ -1088,31 +901,4 @@
 		_connection._responseFields.toString();
 	}
 	
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	/* ------------------------------------------------------------ */
-	private static class NullOutput extends ServletOutputStream
-	{
-		@Override
-		public void write(int b) throws IOException
-		{
-		}
-
-		@Override
-		public void print(String s) throws IOException
-		{
-		}
-
-		@Override
-		public void println(String s) throws IOException
-		{
-		}
-
-		@Override
-		public void write(byte[] b, int off, int len) throws IOException
-		{
-		}
-
-	}
-
 }