diff src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 1020:6be43ef1eb96

HttpHeaderValues uses StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 22:24:41 -0600
parents f126d30e04a4
children e350c11242be
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Mon Oct 31 03:33:42 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Mon Oct 31 22:24:41 2016 -0600
@@ -503,7 +503,7 @@
 		}
 	}
 
-	private void parsedHeader(Buffer name, Buffer value) throws IOException
+	private void parsedHeader(Buffer name, String value) throws IOException
 	{
 		int ho = HttpHeaders.CACHE.getOrdinal(name);
 		switch (ho)
@@ -516,7 +516,7 @@
 			case HttpHeaders.EXPECT_ORDINAL:
 				if (_version>=HttpVersions.HTTP_1_1_ORDINAL)
 				{
-					value = HttpHeaderValues.CACHE.lookup(value);
+//					value = HttpHeaderValues.CACHE.lookup(value);
 					switch(HttpHeaderValues.CACHE.getOrdinal(value))
 					{
 						case HttpHeaderValues.CONTINUE_ORDINAL:
@@ -527,12 +527,12 @@
 							String[] values = value.toString().split(",");
 							for  (int i=0;values!=null && i<values.length;i++)
 							{
-								CachedBuffer cb=HttpHeaderValues.CACHE.get(values[i].trim());
-								if (cb==null)
+								int cb = HttpHeaderValues.CACHE.getOrdinal(values[i].trim());
+								if (cb == -1)
 									_expect = true;
 								else
 								{
-									switch(cb.getOrdinal())
+									switch(cb)
 									{
 										case HttpHeaderValues.CONTINUE_ORDINAL:
 											_expect100Continue = true;
@@ -548,12 +548,12 @@
 
 			case HttpHeaders.ACCEPT_ENCODING_ORDINAL:
 			case HttpHeaders.USER_AGENT_ORDINAL:
-				value = HttpHeaderValues.CACHE.lookup(value);
+//				value = HttpHeaderValues.CACHE.lookup(value);
 				break;
 
 			case HttpHeaders.CONTENT_TYPE_ORDINAL:
-				value = MimeTypes.CACHE.lookup(value);
-				_charset=MimeTypes.getCharsetFromContentType(value);
+//				value = MimeTypes.CACHE.lookup(value);
+				_charset=MimeTypes.getCharsetFromContentType(new ByteArrayBuffer(value));
 				break;
 		}
 
@@ -578,7 +578,7 @@
 				_generator.setHead(_head);
 				if (_parser.isPersistent())
 				{
-					_responseFields.add(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.KEEP_ALIVE_BUFFER);
+					_responseFields.add(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.KEEP_ALIVE);
 					_generator.setPersistent(true);
 				}
 				else if (HttpMethods.CONNECT.equals(_request.getMethod()))
@@ -593,7 +593,7 @@
 
 				if (!_parser.isPersistent())
 				{
-					_responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE_BUFFER);
+					_responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE);
 					_generator.setPersistent(false);
 				}
 
@@ -601,7 +601,7 @@
 				{
 					LOG.debug("!host {}",this);
 					_generator.setResponse(HttpStatus.BAD_REQUEST_400, null);
-					_responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER);
+					_responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE);
 					_generator.completeHeader(_responseFields, true);
 					_generator.complete();
 					return;
@@ -611,7 +611,7 @@
 				{
 					LOG.debug("!expectation {}",this);
 					_generator.setResponse(HttpStatus.EXPECTATION_FAILED_417, null);
-					_responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER);
+					_responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE);
 					_generator.completeHeader(_responseFields, true);
 					_generator.complete();
 					return;
@@ -664,7 +664,7 @@
 		}
 
 		@Override
-		public void parsedHeader(Buffer name, Buffer value) throws IOException
+		public void parsedHeader(Buffer name, String value) throws IOException
 		{
 			AbstractHttpConnection.this.parsedHeader(name, value);
 		}