Index: src/main/java/org/mortbay/jetty/testing/HttpTester.java
===================================================================
--- src/main/java/org/mortbay/jetty/testing/HttpTester.java	(revision 4189)
+++ src/main/java/org/mortbay/jetty/testing/HttpTester.java	(working copy)
@@ -30,6 +30,7 @@
 import org.mortbay.jetty.HttpHeaders;
 import org.mortbay.jetty.HttpParser;
 import org.mortbay.jetty.HttpVersions;
+import org.mortbay.jetty.MimeTypes;
 import org.mortbay.util.ByteArrayOutputStream2;
 
 /* ------------------------------------------------------------ */
@@ -66,10 +67,19 @@
     protected ByteArrayOutputStream2 _parsedContent;
     protected byte[] _genContent;
     
+    private String _charset;
+    private Buffer _contentType;
+    
     public HttpTester()
     {
+        this("UTF-8");
     }
     
+    public HttpTester(String charset)
+    {
+        _charset = charset;
+    }
+    
     public void reset()
     {
         _fields.clear();
@@ -81,6 +91,39 @@
          _parsedContent=null;
          _genContent=null;
     }
+    
+    private String getString(Buffer buffer)
+    {
+        return getString(buffer.asArray());
+    }
+    
+    private String getString(byte[] b)
+    {
+        if(_charset==null)
+            return new String(b);
+        try
+        {
+            return new String(b, _charset);
+        }
+        catch(Exception e)
+        {
+            return new String(b);
+        }
+    }
+    
+    private byte[] getByteArray(String str)
+    {
+        if(_charset==null)
+            return str.getBytes();
+        try
+        {
+            return str.getBytes(_charset);
+        }
+        catch(Exception e)
+        {
+            return str.getBytes();
+        }
+    }
 
     /* ------------------------------------------------------------ */
     /**
@@ -91,19 +134,26 @@
      */
     public String parse(String rawHTTP) throws IOException
     {
-        ByteArrayBuffer buf = new ByteArrayBuffer(rawHTTP);
+        ByteArrayBuffer buf = new ByteArrayBuffer(getByteArray(rawHTTP));
         View view = new View(buf);
         HttpParser parser = new HttpParser(view,new PH());
         parser.parse();
-        return view.toString();
+        return getString(view.asArray());
     }
 
     /* ------------------------------------------------------------ */
     public String generate() throws IOException
     {
+        _contentType = _fields.get(HttpHeaders.CONTENT_TYPE_BUFFER);
+        if(_contentType!=null)
+        {
+            String charset = MimeTypes.getCharsetFromContentType(_contentType);
+            if(charset!=null)
+                _charset = charset;
+        }
         Buffer bb=new ByteArrayBuffer(32*1024 + (_genContent!=null?_genContent.length:0));
         Buffer sb=new ByteArrayBuffer(4*1024);
-        StringEndPoint endp = new StringEndPoint();
+        StringEndPoint endp = new StringEndPoint(_charset);
         HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[]{sb,bb}),endp, sb.capacity(), bb.capacity());
         
         if (_method!=null)
@@ -214,6 +264,18 @@
     {
         _version=version;
     }
+    
+    /* ------------------------------------------------------------ */
+    public String getContentType()
+    {
+        return getString(_contentType);
+    }
+    
+    /* ------------------------------------------------------------ */
+    public String getCharacterEncoding()
+    {
+        return _charset;
+    }
 
     /* ------------------------------------------------------------ */
     /**
@@ -361,9 +423,9 @@
     public String getContent()
     {
         if (_parsedContent!=null)
-            return _parsedContent.toString();
+            return getString(_parsedContent.toByteArray());
         if (_genContent!=null)
-            return new String(_genContent);
+            return getString(_genContent);
         return null;
     }
     
@@ -373,7 +435,7 @@
         _parsedContent=null;
         if (content!=null)
         {
-            _genContent=content.getBytes();
+            _genContent=getByteArray(content);
             setLongHeader(HttpHeaders.CONTENT_LENGTH,_genContent.length);
         }
         else
@@ -389,17 +451,17 @@
         public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException
         {
             reset();
-            _method=method.toString();
-            _uri=url.toString();
-            _version=version.toString();
+            _method=getString(method);
+            _uri=getString(url);
+            _version=getString(version);
         }
 
         public void startResponse(Buffer version, int status, Buffer reason) throws IOException
         {
             reset();
-            _version=version.toString();
+            _version=getString(version);
             _status=status;
-            _reason=reason.toString();
+            _reason=getString(reason);
         }
         
         public void parsedHeader(Buffer name, Buffer value) throws IOException
@@ -409,6 +471,13 @@
 
         public void headerComplete() throws IOException
         {
+            _contentType = _fields.get(HttpHeaders.CONTENT_TYPE_BUFFER);
+            if(_contentType!=null)
+            {
+                String charset = MimeTypes.getCharsetFromContentType(_contentType);
+                if(charset!=null)
+                    _charset = charset;
+            }
         }
 
         public void messageComplete(long contextLength) throws IOException
Index: src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java
===================================================================
--- src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java	(revision 0)
+++ src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java	(revision 0)
@@ -0,0 +1,43 @@
+//========================================================================
+//Copyright 2007 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at 
+//http://www.apache.org/licenses/LICENSE-2.0
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+//========================================================================
+
+package org.mortbay.jetty.testing;
+
+import junit.framework.TestCase;
+
+public class HttpTesterTest extends TestCase
+{
+    
+    public void testCharset() throws Exception
+    {
+        HttpTester tester = new HttpTester();
+        tester.parse(
+                "POST /uri© HTTP/1.1\r\n"+
+                "Host: fakehost\r\n"+
+                "Content-Length: 11\r\n" +
+                "Content-Type: text/plain; charset=utf-8\r\n" +
+                "\r\n" +
+                "123456789©");
+        System.err.println(tester.getMethod());
+        System.err.println(tester.getURI());
+        System.err.println(tester.getVersion());
+        System.err.println(tester.getHeader("Host"));
+        System.err.println(tester.getContentType());
+        System.err.println(tester.getCharacterEncoding());
+        System.err.println(tester.getContent());
+        assertEquals(tester.getContent(), "123456789©");
+        System.err.println(tester.generate());
+    }
+
+}
Index: src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java
===================================================================
--- src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java	(revision 0)
+++ src/test/java/org/mortbay/jetty/testing/HttpTesterTest.java	(revision 0)
@@ -0,0 +1,43 @@
+//========================================================================
+//Copyright 2007 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at 
+//http://www.apache.org/licenses/LICENSE-2.0
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+//========================================================================
+
+package org.mortbay.jetty.testing;
+
+import junit.framework.TestCase;
+
+public class HttpTesterTest extends TestCase
+{
+    
+    public void testCharset() throws Exception
+    {
+        HttpTester tester = new HttpTester();
+        tester.parse(
+                "POST /uri© HTTP/1.1\r\n"+
+                "Host: fakehost\r\n"+
+                "Content-Length: 11\r\n" +
+                "Content-Type: text/plain; charset=utf-8\r\n" +
+                "\r\n" +
+                "123456789©");
+        System.err.println(tester.getMethod());
+        System.err.println(tester.getURI());
+        System.err.println(tester.getVersion());
+        System.err.println(tester.getHeader("Host"));
+        System.err.println(tester.getContentType());
+        System.err.println(tester.getCharacterEncoding());
+        System.err.println(tester.getContent());
+        assertEquals(tester.getContent(), "123456789©");
+        System.err.println(tester.generate());
+    }
+
+}

