changeset 1019:f126d30e04a4

start replacing BufferCache with StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 03:33:42 -0600
parents 4dc1e1a18661
children 6be43ef1eb96
files src/org/eclipse/jetty/http/HttpFields.java src/org/eclipse/jetty/http/HttpGenerator.java src/org/eclipse/jetty/http/HttpMethods.java src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/http/HttpVersions.java src/org/eclipse/jetty/io/AbstractBuffer.java src/org/eclipse/jetty/io/BufferUtil.java src/org/eclipse/jetty/io/StringCache.java src/org/eclipse/jetty/server/AbstractHttpConnection.java
diffstat 9 files changed, 139 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpFields.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpFields.java	Mon Oct 31 03:33:42 2016 -0600
@@ -59,22 +59,19 @@
  * 
  * 
  */
-public class HttpFields
+public final class HttpFields
 {
 	private static final Logger LOG = LoggerFactory.getLogger(HttpFields.class);
 	
-	/* ------------------------------------------------------------ */
-	public static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
-	public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
+	private static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
+	private static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
 	
-	/* ------------------------------------------------------------ */
 	private static final String[] DAYS =
 	{ "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
 	private static final String[] MONTHS =
 	{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"};
 
 	
-	/* ------------------------------------------------------------ */
 	private static class DateGenerator
 	{
 		private final StringBuilder buf = new StringBuilder(32);
@@ -161,8 +158,7 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	private static final ThreadLocal<DateGenerator> __dateGenerator =new ThreadLocal<DateGenerator>()
+	private static final ThreadLocal<DateGenerator> __dateGenerator = new ThreadLocal<DateGenerator>()
 	{
 		@Override
 		protected DateGenerator initialValue()
@@ -175,7 +171,7 @@
 	/**
 	 * Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" 
 	 */
-	public static String formatDate(long date)
+	private static String formatDate(long date)
 	{
 		return __dateGenerator.get().formatDate(date);
 	}
@@ -184,7 +180,7 @@
 	/**
 	 * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
 	 */
-	public static void formatCookieDate(StringBuilder buf, long date)
+	private static void formatCookieDate(StringBuilder buf, long date)
 	{
 		__dateGenerator.get().formatCookieDate(buf,date);
 	}
@@ -193,14 +189,13 @@
 	/**
 	 * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
 	 */
-	public static String formatCookieDate(long date)
+	private static String formatCookieDate(long date)
 	{
 		StringBuilder buf = new StringBuilder(28);
 		formatCookieDate(buf, date);
 		return buf.toString();
 	}
 
-	/* ------------------------------------------------------------ */
 	private final static String __dateReceiveFmt[] =
 	{   
 		"EEE, dd MMM yyyy HH:mm:ss zzz", 
@@ -216,10 +211,9 @@
 		"EEE dd-MMM-yy HH:mm:ss zzz", "EEE dd-MMM-yy HH:mm:ss",
 	};
 
-	/* ------------------------------------------------------------ */
 	private static class DateParser
 	{
-		final SimpleDateFormat _dateReceive[]= new SimpleDateFormat[__dateReceiveFmt.length];
+		final SimpleDateFormat _dateReceive[] = new SimpleDateFormat[__dateReceiveFmt.length];
  
 		long parse(final String dateVal)
 		{
@@ -263,13 +257,6 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	public static long parseDate(String date)
-	{
-		return __dateParser.get().parse(date);
-	}
-
-	/* ------------------------------------------------------------ */
 	private static final ThreadLocal<DateParser> __dateParser =new ThreadLocal<DateParser>()
 	{
 		@Override
@@ -279,12 +266,15 @@
 		}
 	};
 
-	/* -------------------------------------------------------------- */
-	public final static String __01Jan1970=formatDate(0);
-	public final static Buffer __01Jan1970_BUFFER=new ByteArrayBuffer(__01Jan1970);
-	public final static String __01Jan1970_COOKIE = formatCookieDate(0).trim();
+	private final static String __01Jan1970 = formatDate(0);
+	private final static Buffer __01Jan1970_BUFFER = new ByteArrayBuffer(__01Jan1970);
+	private final static String __01Jan1970_COOKIE = formatCookieDate(0).trim();
+
 
-	/* -------------------------------------------------------------- */
+
+
+
+
 	private final ArrayList<Field> _fields = new ArrayList<Field>(20);
 	private final HashMap<Buffer,Field> _names = new HashMap<Buffer,Field>(32);
 	
@@ -336,12 +326,12 @@
 	{
 		final List<String> list = new ArrayList<String>(_fields.size());
 
-	for (Field f : _fields)
-	{
-		if (f!=null)
-			list.add(BufferUtil.to8859_1_String(f._name));
-	}
-	return list;
+		for (Field f : _fields)
+		{
+			if (f!=null)
+				list.add(BufferUtil.to8859_1_String(f._name));
+		}
+		return list;
 	}
 	
 	/* -------------------------------------------------------------- */
--- a/src/org/eclipse/jetty/http/HttpGenerator.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpGenerator.java	Mon Oct 31 03:33:42 2016 -0600
@@ -53,7 +53,7 @@
 	private static final Status[] __status = new Status[HttpStatus.MAX_CODE+1];
 	static
 	{
-		int versionLength=HttpVersions.HTTP_1_1_BUFFER.length();
+		final int versionLength=HttpVersions.HTTP_1_1_BYTES.length;
 
 		for (int i=0;i<__status.length;i++)
 		{
@@ -62,7 +62,8 @@
 				continue;
 			String reason=code.getMessage();
 			byte[] bytes=new byte[versionLength+5+reason.length()+2];
-			HttpVersions.HTTP_1_1_BUFFER.peek(0,bytes, 0, versionLength);
+//			HttpVersions.HTTP_1_1_BUFFER.peek(0,bytes, 0, versionLength);
+			System.arraycopy(HttpVersions.HTTP_1_1_BYTES,0,bytes,0,versionLength);
 			bytes[versionLength+0]=' ';
 			bytes[versionLength+1]=(byte)('0'+i/100);
 			bytes[versionLength+2]=(byte)('0'+(i%100)/10);
@@ -349,7 +350,7 @@
 					_header.put((byte)' ');
 					_header.put(_uri.getBytes("UTF-8")); // TODO check
 					_header.put((byte)' ');
-					_header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BUFFER:HttpVersions.HTTP_1_1_BUFFER);
+					_header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BYTES:HttpVersions.HTTP_1_1_BYTES);
 					_header.put(HttpTokens.CRLF);
 				}
 			}
@@ -373,7 +374,7 @@
 
 					if (status==null)
 					{
-						_header.put(HttpVersions.HTTP_1_1_BUFFER);
+						_header.put(HttpVersions.HTTP_1_1_BYTES);
 						_header.put((byte) ' ');
 						_header.put((byte) ('0' + _status / 100));
 						_header.put((byte) ('0' + (_status % 100) / 10));
--- a/src/org/eclipse/jetty/http/HttpMethods.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpMethods.java	Mon Oct 31 03:33:42 2016 -0600
@@ -18,15 +18,10 @@
 
 package org.eclipse.jetty.http;
 
-import org.eclipse.jetty.io.Buffer;
-import org.eclipse.jetty.io.BufferCache;
+import org.eclipse.jetty.io.StringCache;
 
-/* ------------------------------------------------------------------------------- */
-/** 
- * 
- * 
- */
-public class HttpMethods
+
+public final class HttpMethods
 {
     public final static String GET= "GET",
         POST= "POST",
@@ -48,17 +43,17 @@
         CONNECT_ORDINAL= 8,
         MOVE_ORDINAL= 9;
 
-    public final static BufferCache CACHE= new BufferCache();
+    public final static StringCache CACHE = new StringCache();
 
-    public final static Buffer 
-        GET_BUFFER= CACHE.add(GET, GET_ORDINAL),
-        POST_BUFFER= CACHE.add(POST, POST_ORDINAL),
-        HEAD_BUFFER= CACHE.add(HEAD, HEAD_ORDINAL),
-        PUT_BUFFER= CACHE.add(PUT, PUT_ORDINAL),
-        OPTIONS_BUFFER= CACHE.add(OPTIONS, OPTIONS_ORDINAL),
-        DELETE_BUFFER= CACHE.add(DELETE, DELETE_ORDINAL),
-        TRACE_BUFFER= CACHE.add(TRACE, TRACE_ORDINAL),
-        CONNECT_BUFFER= CACHE.add(CONNECT, CONNECT_ORDINAL),
-        MOVE_BUFFER= CACHE.add(MOVE, MOVE_ORDINAL);
+    public final static byte[] 
+        GET_BYTES= CACHE.add(GET, GET_ORDINAL),
+        POST_BYTES= CACHE.add(POST, POST_ORDINAL),
+        HEAD_BYTES= CACHE.add(HEAD, HEAD_ORDINAL),
+        PUT_BYTES= CACHE.add(PUT, PUT_ORDINAL),
+        OPTIONS_BYTES= CACHE.add(OPTIONS, OPTIONS_ORDINAL),
+        DELETE_BYTES= CACHE.add(DELETE, DELETE_ORDINAL),
+        TRACE_BYTES= CACHE.add(TRACE, TRACE_ORDINAL),
+        CONNECT_BYTES= CACHE.add(CONNECT, CONNECT_ORDINAL),
+        MOVE_BYTES= CACHE.add(MOVE, MOVE_ORDINAL);
 
 }
--- a/src/org/eclipse/jetty/http/HttpParser.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Mon Oct 31 03:33:42 2016 -0600
@@ -67,7 +67,7 @@
 	private Buffer _body; // Buffer for large content
 	private Buffer _buffer; // The current buffer in use (either _header or _content)
 	private CachedBuffer _cached;
-	private final View.CaseInsensitive _tok0 = new View.CaseInsensitive(); // Saved token: header name, request method or response version
+	private String _tok0; // Saved token: header name, request method or response version
 	private final View.CaseInsensitive _tok1 = new View.CaseInsensitive(); // Saved token: header value, request URI or response code
 	private String _multiLineValue;
 	private int _responseStatus; // If >0 then we are parsing a response
@@ -172,7 +172,7 @@
 				return 0;
 
 			if (_buffer==null)
-				_buffer=getHeaderBuffer();
+				_buffer = getHeaderBuffer();
 
 
 			if (_state == STATE_CONTENT && _contentPosition == _contentLength)
@@ -290,8 +290,11 @@
 					case STATE_FIELD0:
 						if (ch == HttpTokens.SPACE)
 						{
-							_tok0.update(_buffer.markIndex(), _buffer.getIndex() - 1);
-							_responseStatus = HttpVersions.CACHE.get(_tok0)==null?-1:0;
+//System.out.println("qqqqqqqqqqqqqqqq a "+_tok0);
+//							_tok0.update(_buffer.markIndex(), _buffer.getIndex() - 1);
+							_tok0 = _buffer.peek(_buffer.markIndex(), _buffer.getIndex() - 1 - _buffer.markIndex()).toString();
+//System.out.println("qqqqqqqqqqqqqqqq b "+_tok0);
+							_responseStatus = !HttpVersions.CACHE.contains(_tok0)?-1:0;
 							_state=STATE_SPACE1;
 							continue;
 						}
@@ -335,7 +338,8 @@
 						{
 							_eol=ch;
 							_state=STATE_HEADER;
-							_tok0.setPutIndex(_tok0.getIndex());
+//							_tok0.setPutIndex(_tok0.getIndex());
+							_tok0 = "";
 							_tok1.setPutIndex(_tok1.getIndex());
 							_multiLineValue=null;
 							continue;
@@ -355,7 +359,7 @@
 						else if (ch < HttpTokens.SPACE && ch>=0)
 						{
 							// HTTP/0.9
-							_handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _buffer.sliceFromMark(), null);
+							_handler.startRequest(_tok0, _buffer.sliceFromMark(), null);
 							_persistent=false;
 							_state=STATE_SEEKING_EOF;
 							_handler.headerComplete();
@@ -376,14 +380,15 @@
 							{
 								_eol=ch;
 								_state=STATE_HEADER;
-								_tok0.setPutIndex(_tok0.getIndex());
+//								_tok0.setPutIndex(_tok0.getIndex());
+								_tok0 = "";
 								_tok1.setPutIndex(_tok1.getIndex());
 								_multiLineValue=null;
 							}
 							else
 							{
 								// HTTP/0.9
-								_handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, null);
+								_handler.startRequest(_tok0, _tok1, null);
 								_persistent=false;
 								_state=STATE_SEEKING_EOF;
 								_handler.headerComplete();
@@ -396,16 +401,17 @@
 					case STATE_FIELD2:
 						if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
 						{
-							Buffer version;
-							if (_responseStatus>0)
+							String version;
+							if (_responseStatus > 0)
 //								_handler.startResponse(version=HttpVersions.CACHE.lookup(_tok0), _responseStatus,_buffer.sliceFromMark());
-								version = HttpVersions.CACHE.lookup(_tok0);
+								version = _tok0;
 							else
-								_handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, version=HttpVersions.CACHE.lookup(_buffer.sliceFromMark()));
+								_handler.startRequest(_tok0, _tok1, version=_buffer.sliceFromMark().toString());
 							_eol=ch;
-							_persistent=HttpVersions.CACHE.getOrdinal(version)>=HttpVersions.HTTP_1_1_ORDINAL;
+							_persistent = HttpVersions.CACHE.getOrdinal(version) >= HttpVersions.HTTP_1_1_ORDINAL;
 							_state=STATE_HEADER;
-							_tok0.setPutIndex(_tok0.getIndex());
+//							_tok0.setPutIndex(_tok0.getIndex());
+							_tok0 = "";
 							_tok1.setPutIndex(_tok1.getIndex());
 							_multiLineValue=null;
 							continue;
@@ -507,7 +513,8 @@
 									}
 
 									_handler.parsedHeader(header, value);
-									_tok0.setPutIndex(_tok0.getIndex());
+//									_tok0.setPutIndex(_tok0.getIndex());
+									_tok0 = "";
 									_tok1.setPutIndex(_tok1.getIndex());
 									_multiLineValue=null;
 								}
@@ -596,14 +603,22 @@
 						{
 							case HttpTokens.CARRIAGE_RETURN:
 							case HttpTokens.LINE_FEED:
-								if (_length > 0)
-									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+								if (_length > 0) {
+//System.out.println("qqqqqqqqqqqqqqqq c "+_tok0);
+//									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+									_tok0 = _buffer.peek(_buffer.markIndex(), _length).toString();
+//System.out.println("qqqqqqqqqqqqqqqq d "+_tok0);
+								}
 								_eol=ch;
 								_state=STATE_HEADER;
 								break;
 							case HttpTokens.COLON:
-								if (_length > 0 && _cached==null)
-									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+								if (_length > 0 && _cached==null) {
+//System.out.println("qqqqqqqqqqqqqqqq e "+_tok0);
+//									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+									_tok0 = _buffer.peek(_buffer.markIndex(), _length).toString();
+//System.out.println("qqqqqqqqqqqqqqqq f "+_tok0);
+								}
 								_length=-1;
 								_state=STATE_HEADER_VALUE;
 								break;
@@ -627,14 +642,22 @@
 						{
 							case HttpTokens.CARRIAGE_RETURN:
 							case HttpTokens.LINE_FEED:
-								if (_length > 0)
-									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+								if (_length > 0) {
+//System.out.println("qqqqqqqqqqqqqqqq g "+_tok0);
+//									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+									_tok0 = _buffer.peek(_buffer.markIndex(),_length).toString();
+//System.out.println("qqqqqqqqqqqqqqqq h "+_tok0);
+								}
 								_eol=ch;
 								_state=STATE_HEADER;
 								break;
 							case HttpTokens.COLON:
-								if (_length > 0 && _cached==null)
-									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+								if (_length > 0 && _cached==null) {
+//System.out.println("qqqqqqqqqqqqqqqq i "+_tok0);
+//									_tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+									_tok0 = _buffer.peek(_buffer.markIndex(),_length).toString();
+//System.out.println("qqqqqqqqqqqqqqqq j "+_tok0);
+								}
 								_length=-1;
 								_state=STATE_HEADER_VALUE;
 								break;
@@ -1041,7 +1064,10 @@
 		if (_header == null)
 		{
 			_header = _buffers.getHeader();
-			_tok0.update(_header);
+//System.out.println("qqqqqqqqqqqqqqqq k "+_tok0);
+//			_tok0.update(_header);
+			_tok0 = "";
+//System.out.println("qqqqqqqqqqqqqqqq l "+_tok0);
 			_tok1.update(_header);
 		}
 		return _header;
@@ -1122,7 +1148,7 @@
 		/**
 		 * This is the method called by parser when the HTTP request line is parsed
 		 */
-		public abstract void startRequest(Buffer method, Buffer url, Buffer version)
+		public abstract void startRequest(String method, Buffer url, String version)
 				throws IOException;
 
 		public void earlyEOF();
--- a/src/org/eclipse/jetty/http/HttpVersions.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpVersions.java	Mon Oct 31 03:33:42 2016 -0600
@@ -18,15 +18,10 @@
 
 package org.eclipse.jetty.http;
 
-import org.eclipse.jetty.io.Buffer;
-import org.eclipse.jetty.io.BufferCache;
+import org.eclipse.jetty.io.StringCache;
 
-/* ------------------------------------------------------------------------------- */
-/** 
- * 
- * 
- */
-public class HttpVersions
+
+public final class HttpVersions
 {
 	public final static String
 		HTTP_0_9 = "",
@@ -38,10 +33,10 @@
 		HTTP_1_0_ORDINAL=10,
 		HTTP_1_1_ORDINAL=11;
 	
-	public final static BufferCache CACHE = new BufferCache();
+	public final static StringCache CACHE = new StringCache();
 	
-    public final static Buffer 
-        HTTP_0_9_BUFFER=CACHE.add(HTTP_0_9,HTTP_0_9_ORDINAL),
-        HTTP_1_0_BUFFER=CACHE.add(HTTP_1_0,HTTP_1_0_ORDINAL),
-        HTTP_1_1_BUFFER=CACHE.add(HTTP_1_1,HTTP_1_1_ORDINAL);
+    public final static byte[] 
+        HTTP_0_9_BYTES=CACHE.add(HTTP_0_9,HTTP_0_9_ORDINAL),
+        HTTP_1_0_BYTES=CACHE.add(HTTP_1_0,HTTP_1_0_ORDINAL),
+        HTTP_1_1_BYTES=CACHE.add(HTTP_1_1,HTTP_1_1_ORDINAL);
 }
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/io/AbstractBuffer.java	Mon Oct 31 03:33:42 2016 -0600
@@ -360,6 +360,7 @@
 		return _view;
 	}
 
+	@Override
 	public int poke(int index, Buffer src)
 	{
 		_hash=0;
@@ -439,7 +440,7 @@
 	public int put(Buffer src)
 	{
 		int pi = putIndex();
-		int l=poke(pi, src);
+		int l = poke(pi, src);
 		setPutIndex(pi + l);
 		return l;
 	}
@@ -593,7 +594,6 @@
 		return buf.toString();
 	}
 
-	/* ------------------------------------------------------------ */
 	@Override
 	public String toString()
 	{
@@ -606,8 +606,8 @@
 		return new String(asArray(), 0, length());
 	}
 
-	/* ------------------------------------------------------------ */
-	public String toString(String charset)
+	@Override
+	public final String toString(String charset)
 	{
 		try
 		{
@@ -624,8 +624,8 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	public String toString(Charset charset)
+	@Override
+	public final String toString(Charset charset)
 	{
 		try
 		{
--- a/src/org/eclipse/jetty/io/BufferUtil.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/io/BufferUtil.java	Mon Oct 31 03:33:42 2016 -0600
@@ -237,7 +237,7 @@
 	
 	public static Buffer toBuffer(long value)
 	{
-		ByteArrayBuffer buf=new ByteArrayBuffer(32);
+		ByteArrayBuffer buf = new ByteArrayBuffer(32);
 		putDecLong(buf, value);
 		return buf;
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/eclipse/jetty/io/StringCache.java	Mon Oct 31 03:33:42 2016 -0600
@@ -0,0 +1,28 @@
+// to replace BufferCache
+
+package org.eclipse.jetty.io;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.jetty.util.StringUtil;
+
+
+public class StringCache {
+	private final Map<String,Integer> stringToOrdinal = new HashMap<String,Integer>();
+//	private final Map<Integer,String> ordinalToString = new HashMap<Integer,String>();
+
+	public byte[] add(String value, int ordinal) {
+		stringToOrdinal.put(value.toLowerCase(), ordinal);
+//		ordinalToString.put(ordinal, value);
+		return StringUtil.getBytes(value);
+	}
+
+	public int getOrdinal(String value) {
+		Integer i = stringToOrdinal.get(value.toLowerCase());
+		return i==null ? -1 : i;
+	}
+
+	public boolean contains(String value) {
+		return stringToOrdinal.containsKey(value.toLowerCase());
+	}
+}
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java	Mon Oct 31 03:33:42 2016 -0600
@@ -446,7 +446,7 @@
 				_parser);
 	}
 
-	private void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
+	private void startRequest(String method, Buffer uri, String version) throws IOException
 	{
 		uri=uri.asImmutableBuffer();
 
@@ -458,7 +458,7 @@
 
 		if(_request.getTimeStamp()==0)
 			_request.setTimeStamp(System.currentTimeMillis());
-		_request.setMethod(method.toString());
+		_request.setMethod(method);
 
 		try
 		{
@@ -487,8 +487,7 @@
 			}
 			else
 			{
-				version = HttpVersions.CACHE.get(version);
-				if (version==null)
+				if (!HttpVersions.CACHE.contains(version))
 					throw new HttpException(HttpStatus.BAD_REQUEST_400,null);
 				_version = HttpVersions.CACHE.getOrdinal(version);
 				if (_version <= 0) _version = HttpVersions.HTTP_1_0_ORDINAL;
@@ -659,7 +658,7 @@
 	private class RequestHandler implements HttpParser.EventHandler
 	{
 		@Override
-		public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
+		public void startRequest(String method, Buffer uri, String version) throws IOException
 		{
 			AbstractHttpConnection.this.startRequest(method, uri, version);
 		}