hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1327298 [1/2] - in /httpcomponents/httpcore/trunk: httpcore-ab/src/main/java/org/apache/http/benchmark/ httpcore-nio/src/examples/org/apache/http/examples/nio/ httpcore-nio/src/main/java/org/apache/http/nio/entity/ httpcore-nio/src/main/ja...
Date Tue, 17 Apr 2012 21:47:27 GMT
Author: olegk
Date: Tue Apr 17 21:47:26 2012
New Revision: 1327298

URL: http://svn.apache.org/viewvc?rev=1327298&view=rev
Log:
HTTPCORE-297: ContentType to use Charset instead of String to represent the charset parameter

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/Consts.java
      - copied, changed from r1326378, httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java
Modified:
    httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
    httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/RequestHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/SimpleRequestHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestPipelining.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HTTP.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestContentType.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestSessionBuffers.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java

Modified: httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java Tue Apr 17 21:47:26 2012
@@ -30,6 +30,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetSocketAddress;
 import java.net.Socket;
+import java.nio.charset.Charset;
 
 import javax.net.SocketFactory;
 
@@ -183,9 +184,9 @@ class BenchmarkWorker implements Runnabl
                 HttpEntity entity = response.getEntity();
                 if (entity != null) {
                     ContentType ct = ContentType.get(entity);
-                    String charset = ct.getCharset();
+                    Charset charset = ct.getCharset();
                     if (charset == null) {
-                        charset = HTTP.DEFAULT_CONTENT_CHARSET;
+                        charset = HTTP.DEF_CONTENT_CHARSET;
                     }
                     long contentlen = 0;
                     InputStream instream = entity.getContent();
@@ -193,7 +194,7 @@ class BenchmarkWorker implements Runnabl
                     while ((l = instream.read(this.buffer)) != -1) {
                         contentlen += l;
                         if (this.verbosity >= 4) {
-                            String s = new String(this.buffer, 0, l, charset);
+                            String s = new String(this.buffer, 0, l, charset.name());
                             System.out.print(s);
                         }
                     }

Modified: httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java Tue Apr 17 21:47:26 2012
@@ -122,7 +122,7 @@ public class HttpBenchmark {
             fe.setChunked(config.isUseChunking());
             entity = fe;
         } else if (config.getPayloadText() != null) {
-            StringEntity se = StringEntity.create(config.getPayloadText(), 
+            StringEntity se = new StringEntity(config.getPayloadText(), 
                     ContentType.parse(config.getContentType()));
             se.setChunked(config.isUseChunking());
             entity = se;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java Tue Apr 17 21:47:26 2012
@@ -388,7 +388,7 @@ public class NHttpReverseProxy {
                     if (message == null) {
                         message = "Unexpected error";
                     }
-                    response.setEntity(NStringEntity.create(message, ContentType.DEFAULT_TEXT));
+                    response.setEntity(new NStringEntity(message, ContentType.DEFAULT_TEXT));
                     responseTrigger.submitResponse(new BasicAsyncResponseProducer(response));
                     System.out.println("[client<-proxy] " + httpExchange.getId() + " error response triggered");
                 }
@@ -665,7 +665,7 @@ public class NHttpReverseProxy {
                     if (message == null) {
                         message = "Unexpected error";
                     }
-                    response.setEntity(NStringEntity.create(message, ContentType.DEFAULT_TEXT));
+                    response.setEntity(new NStringEntity(message, ContentType.DEFAULT_TEXT));
                     responseTrigger.submitResponse(new BasicAsyncResponseProducer(response));
                 }
             }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java Tue Apr 17 21:47:26 2012
@@ -231,7 +231,7 @@ public class NHttpServer {
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 response.setStatusCode(HttpStatus.SC_OK);
-                NFileEntity body = new NFileEntity(file, ContentType.create("text/html", null));
+                NFileEntity body = new NFileEntity(file, ContentType.create("text/html"));
                 response.setEntity(body);
                 System.out.println(conn + ": serving file " + file.getPath());
             }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java Tue Apr 17 21:47:26 2012
@@ -33,6 +33,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.entity.AbstractHttpEntity;
@@ -63,81 +65,28 @@ public class NStringEntity extends Abstr
     /**
      * Creates a NStringEntity with the specified content and content type.
      *
-     * @param string content to be used. Not {@code null}.
-     * @param contentType content type to be used. May be {@code null}, in which case the default
-     *   MIME type {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain" and the default charset
-     *   {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1" are assumed.
-     *
-     * @throws IllegalArgumentException if the string parameter is null or if the charset
-     *   specified in the CotnentType is not supported.
-     *
-     * @since 4.2
-     */
-    public static NStringEntity create(final String string, final ContentType contentType) {
-        try {
-            return new NStringEntity(string, contentType);
-        } catch (UnsupportedEncodingException ex) {
-            throw new IllegalArgumentException(ex.getMessage(), ex);
-        }
-    }
-
-    /**
-     * Creates a StringEntity with the specified content and charset. The mime type defaults
-     * to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     *
-     * @param string content to be used. Not {@code null}.
-     * @param charset character set to be used. May be {@code null}, in which case the default
-     *   is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
-     *
-     * @throws IllegalArgumentException if the string parameter is null or if the charset
-     *   specified in the CotnentType is not supported.
-     *
-     * @since 4.2
-     */
-    public static NStringEntity create(
-            final String string, final String charset) {
-        return create(string, ContentType.create(HTTP.PLAIN_TEXT_TYPE, charset));
-    }
-
-    /**
-     * Creates a StringEntity with the specified content and charset. The charset defaults to
-     * {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1". The mime type defaults to
-     * {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     *
-     * @param string content to be used. Not {@code null}.
-     *
-     * @throws IllegalArgumentException if the string parameter is null
-     *
-     * @since 4.2
-     */
-    public static NStringEntity create(final String string) {
-        return create(string, ContentType.DEFAULT_TEXT);
-    }
-
-    /**
-     * Creates a NStringEntity with the specified content and content type.
-     *
      * @param s content to be used. Not {@code null}.
-     * @param contentType content type to be used. May be {@code null}, in which case the default
-     *   MIME type {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain" and the default charset
-     *   {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1" are assumed.
+     * @param contentType content type to be used. May be {@code null}, in which case 
+     * {@link ContentType#TEXT_PLAIN} is assumed.
      *
      * @throws IllegalArgumentException if the string parameter is null
-     * @throws UnsupportedEncodingException if the charset specified in the CotnentType
-     *   is not supported.
      *
      * @since 4.2
      */
-    public NStringEntity(final String s, final ContentType contentType)
-            throws UnsupportedEncodingException {
+    public NStringEntity(final String s, final ContentType contentType) {
         if (s == null) {
             throw new IllegalArgumentException("Source string may not be null");
         }
-        String charset = contentType != null ? contentType.getCharset() : null;
+        Charset charset = contentType != null ? contentType.getCharset() : null;
         if (charset == null) {
-            charset = HTTP.DEFAULT_CONTENT_CHARSET;
+            charset = HTTP.DEF_CONTENT_CHARSET;
+        }
+        try {
+            this.b = s.getBytes(charset.name());
+        } catch (UnsupportedEncodingException ex) {
+            // should never happen
+            throw new UnsupportedCharsetException(charset.name());
         }
-        this.b = s.getBytes(charset);
         this.buf = ByteBuffer.wrap(this.b);
         this.content = b;
         this.buffer = this.buf;
@@ -148,24 +97,23 @@ public class NStringEntity extends Abstr
 
     /**
      * Creates a NStringEntity with the specified content and charset. The mime type defaults
-     * to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * to "text/plain".
      *
-     * @param s content to be used. Not {@code null}.
+     * @param string content to be used. Not {@code null}.
      * @param charset character set to be used. May be {@code null}, in which case the default
-     *   is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
+     *   is {@link HTTP#DEF_CONTENT_CHARSET} is assumed
      *
      * @throws IllegalArgumentException if the string parameter is null
      * @throws UnsupportedEncodingException if the charset is not supported.
      */
     public NStringEntity(final String s, final String charset)
             throws UnsupportedEncodingException {
-        this(s, ContentType.create(HTTP.PLAIN_TEXT_TYPE, charset));
+        this(s, ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), charset));
     }
 
     /**
-     * Creates a StringEntity with the specified content and charset. The charset defaults to
-     * {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1". The mime type defaults to
-     * {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * Creates a NStringEntity with the specified content. The content type defaults to
+     * {@link ContentType#TEXT_PLAIN}.
      *
      * @param s content to be used. Not {@code null}.
      *

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java Tue Apr 17 21:47:26 2012
@@ -46,6 +46,7 @@ import org.apache.http.ProtocolException
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.concurrent.Cancellable;
+import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
@@ -481,7 +482,8 @@ public class HttpAsyncService implements
         }
         HttpResponse response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
                 code, context);
-        return new ErrorResponseProducer(response, NStringEntity.create(message), false);
+        return new ErrorResponseProducer(response, 
+                new NStringEntity(message, ContentType.DEFAULT_TEXT), false);
     }
 
     private boolean canResponseHaveBody(final HttpRequest request, final HttpResponse response) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java Tue Apr 17 21:47:26 2012
@@ -30,6 +30,7 @@ package org.apache.http.nio.protocol;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.entity.ContentType;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.protocol.HttpContext;
 
@@ -51,7 +52,7 @@ class NullRequestHandler implements Http
         HttpResponse response = httpexchange.getResponse();
         response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
         httpexchange.submitResponse(new ErrorResponseProducer(
-                response, NStringEntity.create("Service not implemented"), true));
+                response, new NStringEntity("Service not implemented", ContentType.TEXT_PLAIN), true));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/RequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/RequestHandler.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/RequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/RequestHandler.java Tue Apr 17 21:47:26 2012
@@ -95,7 +95,7 @@ final class RequestHandler extends Simpl
             }
             content = buffer.toString();
         }
-        NStringEntity entity = NStringEntity.create(content, ContentType.DEFAULT_TEXT);
+        NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
         entity.setChunked(this.chunking);
         response.setEntity(entity);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/SimpleRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/SimpleRequestHandler.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/SimpleRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/SimpleRequestHandler.java Tue Apr 17 21:47:26 2012
@@ -83,7 +83,7 @@ final class SimpleRequestHandler impleme
             }
             content = buffer.toString();
         }
-        NStringEntity entity = NStringEntity.create(content, ContentType.DEFAULT_TEXT);
+        NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
         entity.setChunked(this.chunking);
         response.setEntity(entity);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java Tue Apr 17 21:47:26 2012
@@ -233,7 +233,7 @@ public class TestHttpAsyncHandlers exten
         for (int i = 0; i < 30; i++) {
             BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                     "POST", createRequestUri(pattern, count));
-            NStringEntity entity = NStringEntity.create(expectedPattern, ContentType.DEFAULT_TEXT);
+            NStringEntity entity = new NStringEntity(expectedPattern, ContentType.DEFAULT_TEXT);
             request.setEntity(entity);
             Future<HttpResponse> future = this.executor.execute(
                     new BasicAsyncRequestProducer(target, request),
@@ -269,7 +269,7 @@ public class TestHttpAsyncHandlers exten
         for (int i = 0; i < 30; i++) {
             BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                     "POST", createRequestUri(pattern, count));
-            NStringEntity entity = NStringEntity.create(expectedPattern, ContentType.DEFAULT_TEXT);
+            NStringEntity entity = new NStringEntity(expectedPattern, ContentType.DEFAULT_TEXT);
             entity.setChunked(true);
             request.setEntity(entity);
             Future<HttpResponse> future = this.executor.execute(
@@ -306,7 +306,7 @@ public class TestHttpAsyncHandlers exten
         for (int i = 0; i < 30; i++) {
             BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                     "POST", createRequestUri(pattern, count), HttpVersion.HTTP_1_0);
-            NStringEntity entity = NStringEntity.create(expectedPattern, ContentType.DEFAULT_TEXT);
+            NStringEntity entity = new NStringEntity(expectedPattern, ContentType.DEFAULT_TEXT);
             request.setEntity(entity);
             Future<HttpResponse> future = this.executor.execute(
                     new BasicAsyncRequestProducer(target, request),
@@ -466,7 +466,7 @@ public class TestHttpAsyncHandlers exten
             BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                     "POST", createRequestUri(pattern, count));
             request.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-            NStringEntity entity = NStringEntity.create(expectedPattern, ContentType.DEFAULT_TEXT);
+            NStringEntity entity = new NStringEntity(expectedPattern, ContentType.DEFAULT_TEXT);
             request.setEntity(entity);
             Future<HttpResponse> future = this.executor.execute(
                     new BasicAsyncRequestProducer(target, request),
@@ -499,7 +499,7 @@ public class TestHttpAsyncHandlers exten
                     }
                     BasicHttpResponse response = new BasicHttpResponse(ver,
                             HttpStatus.SC_EXPECTATION_FAILED, "Expectation failed");
-                    response.setEntity(NStringEntity.create("Expectation failed"));
+                    response.setEntity(new NStringEntity("Expectation failed", ContentType.TEXT_PLAIN));
                     httpexchange.submitResponse(new BasicAsyncResponseProducer(response));
                 } else {
                     httpexchange.submitResponse();
@@ -515,15 +515,15 @@ public class TestHttpAsyncHandlers exten
         BasicHttpEntityEnclosingRequest request1 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("AAAAA", 10));
         request1.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request1.setEntity(NStringEntity.create(createExpectedString("AAAAA", 10)));
+        request1.setEntity(new NStringEntity(createExpectedString("AAAAA", 10)));
         BasicHttpEntityEnclosingRequest request2 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("AAAAA", 10));
         request2.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request2.setEntity(NStringEntity.create(createExpectedString("AAAAA", 10)));
+        request2.setEntity(new NStringEntity(createExpectedString("AAAAA", 10)));
         BasicHttpEntityEnclosingRequest request3 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("BBBBB", 10));
         request3.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request3.setEntity(NStringEntity.create(createExpectedString("BBBBB", 10)));
+        request3.setEntity(new NStringEntity(createExpectedString("BBBBB", 10)));
 
         HttpRequest[] requests = new HttpRequest[] { request1, request2, request3 };
 
@@ -648,7 +648,7 @@ public class TestHttpAsyncHandlers exten
                             }
                             BasicHttpResponse response = new BasicHttpResponse(ver,
                                     HttpStatus.SC_EXPECTATION_FAILED, "Expectation failed");
-                            response.setEntity(NStringEntity.create("Expectation failed"));
+                            response.setEntity(new NStringEntity("Expectation failed", ContentType.TEXT_PLAIN));
                             httpexchange.submitResponse(new BasicAsyncResponseProducer(response));
                         } else {
                             httpexchange.submitResponse();
@@ -666,15 +666,15 @@ public class TestHttpAsyncHandlers exten
         BasicHttpEntityEnclosingRequest request1 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("AAAAA", 10));
         request1.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request1.setEntity(NStringEntity.create(createExpectedString("AAAAA", 10)));
+        request1.setEntity(new NStringEntity(createExpectedString("AAAAA", 10)));
         BasicHttpEntityEnclosingRequest request2 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("AAAAA", 10));
         request2.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request2.setEntity(NStringEntity.create(createExpectedString("AAAAA", 10)));
+        request2.setEntity(new NStringEntity(createExpectedString("AAAAA", 10)));
         BasicHttpEntityEnclosingRequest request3 = new BasicHttpEntityEnclosingRequest(
                 "POST", createRequestUri("BBBBB", 10));
         request3.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        request3.setEntity(NStringEntity.create(createExpectedString("BBBBB", 10)));
+        request3.setEntity(new NStringEntity(createExpectedString("BBBBB", 10)));
 
         HttpRequest[] requests = new HttpRequest[] { request1, request2, request3 };
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestPipelining.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestPipelining.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestPipelining.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestPipelining.java Tue Apr 17 21:47:26 2012
@@ -116,7 +116,7 @@ public class TestPipelining extends Http
                     final HttpResponse response,
                     final HttpContext context) throws HttpException, IOException {
                 String content = "thank you very much";
-                NStringEntity entity = NStringEntity.create(content, ContentType.DEFAULT_TEXT);
+                NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
                 response.setEntity(entity);
             }
 
@@ -214,7 +214,7 @@ public class TestPipelining extends Http
                     final HttpResponse response,
                     final HttpContext context) throws HttpException, IOException {
                 String content = "thank you very much";
-                NStringEntity entity = NStringEntity.create(content, ContentType.DEFAULT_TEXT);
+                NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
                 response.setEntity(entity);
             }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestThrottlingNHttpHandlers.java Tue Apr 17 21:47:26 2012
@@ -32,6 +32,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.InetSocketAddress;
+import java.nio.charset.Charset;
 import java.util.LinkedList;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -740,11 +741,11 @@ public class TestThrottlingNHttpHandlers
                             outstream.write(tmp, 0, l);
                         }
                         ContentType contentType = ContentType.getOrDefault(entity);
-                        String charset = contentType.getCharset();
+                        Charset charset = contentType.getCharset();
                         if (charset == null) {
-                            charset = HTTP.DEFAULT_CONTENT_CHARSET;
+                            charset = HTTP.DEF_CONTENT_CHARSET;
                         }
-                        content = new String(outstream.toByteArray(), charset);
+                        content = new String(outstream.toByteArray(), charset.name());
                     } catch (InterruptedException ex) {
                         content = "Interrupted: " + ex.getMessage();
                     } catch (IOException ex) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java Tue Apr 17 21:47:26 2012
@@ -34,6 +34,7 @@ import java.nio.channels.WritableByteCha
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
+import org.apache.http.Consts;
 import org.apache.http.HttpCoreNIOTestBase;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
@@ -74,7 +75,6 @@ import org.apache.http.nio.util.ByteBuff
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.nio.util.SimpleInputBuffer;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.CharArrayBuffer;
 import org.apache.http.util.EntityUtils;
@@ -307,7 +307,7 @@ public class TestTruncatedChunks extends
         HttpResponse response = future.get();
         Assert.assertNotNull(response);
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        Assert.assertEquals(new String(GARBAGE, HTTP.DEFAULT_CONTENT_CHARSET),
+        Assert.assertEquals(new String(GARBAGE, Consts.ISO_8859_1.name()),
                 EntityUtils.toString(response.getEntity()));
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java Tue Apr 17 21:47:26 2012
@@ -214,7 +214,7 @@ public class TestHttpAsyncRequestExecuto
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.exchangeHandler.generateRequest()).thenReturn(request);
 
         this.protocolHandler.requestReady(this.conn);
@@ -312,7 +312,7 @@ public class TestHttpAsyncRequestExecuto
         state.setRequestState(MessageState.ACK_EXPECTED);
         state.setTimeout(1000);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         state.setRequest(request);
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
@@ -333,7 +333,7 @@ public class TestHttpAsyncRequestExecuto
         State state = new HttpAsyncRequestExecutor.State();
         state.setRequestState(MessageState.COMPLETED);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         state.setRequest(request);
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
@@ -353,7 +353,7 @@ public class TestHttpAsyncRequestExecuto
         state.setRequestState(MessageState.ACK_EXPECTED);
         state.setTimeout(1000);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         state.setRequest(request);
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
@@ -369,7 +369,7 @@ public class TestHttpAsyncRequestExecuto
         state.setRequestState(MessageState.ACK_EXPECTED);
         state.setTimeout(1000);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         state.setRequest(request);
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);
@@ -391,7 +391,7 @@ public class TestHttpAsyncRequestExecuto
         state.setRequestState(MessageState.BODY_STREAM);
         state.setTimeout(1000);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         state.setRequest(request);
         state.setHandler(this.exchangeHandler);
         this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java Tue Apr 17 21:47:26 2012
@@ -326,7 +326,7 @@ public class TestHttpAsyncService {
 
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
                 "/stuff", HttpVersion.HTTP_1_1);
-        request.setEntity(NStringEntity.create("stuff"));
+        request.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
         Mockito.when(this.requestHandler.processRequest(
                 request, exchangeContext)).thenReturn(this.requestConsumer);
@@ -689,7 +689,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
 
         this.protocolHandler.responseReady(this.conn);
@@ -715,7 +715,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
         Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(true);
 
@@ -743,7 +743,7 @@ public class TestHttpAsyncService {
 
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                 HttpStatus.SC_NOT_MODIFIED, "Not modified");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
         Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(true);
 
@@ -802,7 +802,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 417, "Expectation failed");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
 
         this.protocolHandler.responseReady(this.conn);
@@ -846,7 +846,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
         Mockito.when(this.conn.isResponseSubmitted()).thenReturn(false);
 
@@ -898,7 +898,7 @@ public class TestHttpAsyncService {
     public void testResponseContent() throws Exception {
         State state = new HttpAsyncService.State();
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         state.setRequestState(MessageState.COMPLETED);
         state.setResponseState(MessageState.BODY_STREAM);
         state.setResponse(response);
@@ -921,7 +921,7 @@ public class TestHttpAsyncService {
         State state = new HttpAsyncService.State();
         HttpContext exchangeContext = state.getContext();
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         state.setRequestState(MessageState.COMPLETED);
         state.setResponseState(MessageState.BODY_STREAM);
         state.setResponse(response);
@@ -946,7 +946,7 @@ public class TestHttpAsyncService {
         State state = new HttpAsyncService.State();
         HttpContext exchangeContext = state.getContext();
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        response.setEntity(NStringEntity.create("stuff"));
+        response.setEntity(new NStringEntity("stuff"));
         state.setRequestState(MessageState.COMPLETED);
         state.setResponseState(MessageState.BODY_STREAM);
         state.setResponse(response);

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java Tue Apr 17 21:47:26 2012
@@ -33,6 +33,7 @@ import java.io.InterruptedIOException;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.URLDecoder;
+import java.nio.charset.Charset;
 import java.util.Locale;
 
 import org.apache.http.ConnectionClosedException;
@@ -137,7 +138,7 @@ public class ElementalHttpServer {
             } else {
 
                 response.setStatusCode(HttpStatus.SC_OK);
-                FileEntity body = new FileEntity(file, ContentType.create("text/html", null));
+                FileEntity body = new FileEntity(file, ContentType.create("text/html", (Charset) null));
                 response.setEntity(body);
                 System.out.println("Serving file " + file.getPath());
             }

Copied: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/Consts.java (from r1326378, httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/Consts.java?p2=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/Consts.java&p1=httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java&r1=1326378&r2=1327298&rev=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/Consts.java Tue Apr 17 21:47:26 2012
@@ -25,33 +25,27 @@
  *
  */
 
-package org.apache.http.nio.protocol;
+package org.apache.http;
 
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.nio.entity.NStringEntity;
-import org.apache.http.protocol.HttpContext;
+import java.nio.charset.Charset;
 
-class NullRequestHandler implements HttpAsyncRequestHandler<Object> {
-
-    public NullRequestHandler() {
-        super();
-    }
+/**
+ * Commons constants.
+ *
+ * @since 4.2
+ */
+public final class Consts {
 
-    public HttpAsyncRequestConsumer<Object> processRequest(
-            final HttpRequest request, final HttpContext context) {
-        return new NullRequestConsumer();
-    }
+    public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
+    public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
+    public static final int SP = 32; // <US-ASCII SP, space (32)>
+    public static final int HT = 9;  // <US-ASCII HT, horizontal-tab (9)>
+
+    public static final Charset UTF_8 = Charset.forName("UTF-8");
+    public static final Charset ASCII = Charset.forName("US-ASCII");
+    public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
 
-    public void handle(
-            final Object obj,
-            final HttpAsyncExchange httpexchange,
-            final HttpContext context) {
-        HttpResponse response = httpexchange.getResponse();
-        response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
-        httpexchange.submitResponse(new ErrorResponseProducer(
-                response, NStringEntity.create("Service not implemented"), true));
+    private Consts() {
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java Tue Apr 17 21:47:26 2012
@@ -27,8 +27,11 @@
 
 package org.apache.http.entity;
 
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
 import java.util.Locale;
 
+import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
@@ -36,7 +39,6 @@ import org.apache.http.NameValuePair;
 import org.apache.http.ParseException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicHeaderValueParser;
-import org.apache.http.protocol.HTTP;
 
 /**
  * Content type information consisting of a MIME type and an optional charset.
@@ -51,44 +53,46 @@ import org.apache.http.protocol.HTTP;
 public final class ContentType {
 
     // constants
-    public static final ContentType APPLICATION_ATOM_XML = new ContentType(
-            "application/atom+xml", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType APPLICATION_FORM_URLENCODED = new ContentType(
-            "application/x-www-form-urlencoded", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType APPLICATION_JSON = new ContentType(
-            "application/json", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType APPLICATION_OCTET_STREAM = new ContentType(
-            "application/octet-stream", null);
-    public static final ContentType APPLICATION_SVG_XML = new ContentType(
-            "application/svg+xml", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType APPLICATION_XHTML_XML = new ContentType(
-            "application/xhtml+xml", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType APPLICATION_XML = new ContentType(
-            "application/xml", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType MULTIPART_FORM_DATA = new ContentType(
-            "multipart/form-data", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType TEXT_HTML = new ContentType(
-            "text/html", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType TEXT_PLAIN = new ContentType(
-            "text/plain", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType TEXT_XML = new ContentType(
-            "text/xml", HTTP.DEFAULT_CONTENT_CHARSET);
-    public static final ContentType WILDCARD = new ContentType(
-            "*/*", null);
+    public static final ContentType APPLICATION_ATOM_XML = create(
+            "application/atom+xml", Consts.ISO_8859_1);
+    public static final ContentType APPLICATION_FORM_URLENCODED = create(
+            "application/x-www-form-urlencoded", Consts.ISO_8859_1);
+    public static final ContentType APPLICATION_JSON = create(
+            "application/json", Consts.ISO_8859_1);
+    public static final ContentType APPLICATION_OCTET_STREAM = create(
+            "application/octet-stream", (Charset) null);
+    public static final ContentType APPLICATION_SVG_XML = create(
+            "application/svg+xml", Consts.ISO_8859_1);
+    public static final ContentType APPLICATION_XHTML_XML = create(
+            "application/xhtml+xml", Consts.ISO_8859_1);
+    public static final ContentType APPLICATION_XML = create(
+            "application/xml", Consts.ISO_8859_1);
+    public static final ContentType MULTIPART_FORM_DATA = create(
+            "multipart/form-data", Consts.ISO_8859_1);
+    public static final ContentType TEXT_HTML = create(
+            "text/html", Consts.ISO_8859_1);
+    public static final ContentType TEXT_PLAIN = create(
+            "text/plain", Consts.ISO_8859_1);
+    public static final ContentType TEXT_XML = create(
+            "text/xml", Consts.ISO_8859_1);
+    public static final ContentType WILDCARD = create(
+            "*/*", (Charset) null);
 
     // defaults
     public static final ContentType DEFAULT_TEXT = TEXT_PLAIN;
     public static final ContentType DEFAULT_BINARY = APPLICATION_OCTET_STREAM;
 
     private final String mimeType;
-    private final String charset;
+    private final Charset charset;
 
     /**
      * Given a mime type and a character set, constructs a ContentType.
      * @param mimeType The mime type to use for the ContentType header.
      * @param charset The optional character set to use with the ContentType header.
+     * @throws  UnsupportedCharsetException
+     *          If no support for the named charset is available in this Java virtual machine
      */
-    ContentType(final String mimeType, final String charset) {
+    ContentType(final String mimeType, final Charset charset) {
         this.mimeType = mimeType;
         this.charset = charset;
     }
@@ -97,7 +101,7 @@ public final class ContentType {
         return this.mimeType;
     }
 
-    public String getCharset() {
+    public Charset getCharset() {
         return this.charset;
     }
 
@@ -131,11 +135,10 @@ public final class ContentType {
      *
      * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
      *        characters <">, <;>, <,> reserved by the HTTP specification.
-     * @param charset charset. It may not contain characters <">, <;>, <,> reserved by the HTTP
-     *        specification. This parameter is optional.
+     * @param charset charset.
      * @return content type
      */
-    public static ContentType create(final String mimeType, final String charset) {
+    public static ContentType create(final String mimeType, final Charset charset) {
         if (mimeType == null) {
             throw new IllegalArgumentException("MIME type may not be null");
         }
@@ -146,14 +149,32 @@ public final class ContentType {
         if (!valid(type)) {
             throw new IllegalArgumentException("MIME type may not contain reserved characters");
         }
-        String cs = null;
-        if (charset != null) {
-            cs = charset.trim().toLowerCase(Locale.US);
-            if (!valid(cs)) {
-                throw new IllegalArgumentException("Charset may not contain reserved characters");
-            }
-        }
-        return new ContentType(type, cs);
+        return new ContentType(type, charset);
+    }
+
+    /**
+     * Creates a new instance of {@link ContentType} without a charset.
+     *
+     * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
+     *        characters <">, <;>, <,> reserved by the HTTP specification.
+     * @return content type
+     */
+    public static ContentType create(final String mimeType) {
+        return new ContentType(mimeType, (Charset) null);
+    }
+    
+    /**
+     * Creates a new instance of {@link ContentType}.
+     *
+     * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
+     *        characters <">, <;>, <,> reserved by the HTTP specification.
+     * @param charset charset. It may not contain characters <">, <;>, <,> reserved by the HTTP
+     *        specification. This parameter is optional.
+     * @return content type
+     */
+    public static ContentType create(
+            final String mimeType, final String charset) throws UnsupportedCharsetException {
+        return create(mimeType, charset != null ? Charset.forName(charset) : null);
     }
 
     private static ContentType create(final HeaderElement helem) {
@@ -174,7 +195,8 @@ public final class ContentType {
      * @throws ParseException if the given text does not represent a valid
      * <code>Content-Type</code> value.
      */
-    public static ContentType parse(final String s) throws ParseException {
+    public static ContentType parse(
+            final String s) throws ParseException, UnsupportedCharsetException {
         if (s == null) {
             throw new IllegalArgumentException("Content type may not be null");
         }
@@ -196,7 +218,8 @@ public final class ContentType {
      * @throws ParseException if the given text does not represent a valid
      * <code>Content-Type</code> value.
      */
-    public static ContentType get(final HttpEntity entity) throws ParseException {
+    public static ContentType get(
+            final HttpEntity entity) throws ParseException, UnsupportedCharsetException {
         if (entity == null) {
             return null;
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java Tue Apr 17 21:47:26 2012
@@ -32,6 +32,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.protocol.HTTP;
@@ -52,80 +54,27 @@ public class StringEntity extends Abstra
      *
      * @param string content to be used. Not {@code null}.
      * @param contentType content type to be used. May be {@code null}, in which case the default
-     *   MIME type {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain" and the default charset
-     *   {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1" are assumed.
-     *
-     * @throws IllegalArgumentException if the string parameter is null or if the charset
-     *   specified in the CotnentType is not supported.
-     *
-     * @since 4.2
-     */
-    public static StringEntity create(final String string, final ContentType contentType) {
-        try {
-            return new StringEntity(string, contentType);
-        } catch (UnsupportedEncodingException ex) {
-            throw new IllegalArgumentException(ex.getMessage(), ex);
-        }
-    }
-
-    /**
-     * Creates a StringEntity with the specified content and charset. The mime type defaults
-     * to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     *
-     * @param string content to be used. Not {@code null}.
-     * @param charset character set to be used. May be {@code null}, in which case the default
-     *   is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
-     *
-     * @throws IllegalArgumentException if the string parameter is null or if the charset
-     *   specified in the CotnentType is not supported.
-     *
-     * @since 4.2
-     */
-    public static StringEntity create(
-            final String string, final String charset) {
-        return create(string, ContentType.create(HTTP.PLAIN_TEXT_TYPE, charset));
-    }
-
-    /**
-     * Creates a StringEntity with the specified content and charset. The charset defaults to
-     * {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1". The mime type defaults to
-     * {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     *
-     * @param string content to be used. Not {@code null}.
-     *
-     * @throws IllegalArgumentException if the string parameter is null
-     *
-     * @since 4.2
-     */
-    public static StringEntity create(final String string) {
-        return create(string, ContentType.DEFAULT_TEXT);
-    }
-
-    /**
-     * Creates a StringEntity with the specified content and content type.
-     *
-     * @param string content to be used. Not {@code null}.
-     * @param contentType content type to be used. May be {@code null}, in which case the default
-     *   MIME type {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain" and the default charset
-     *   {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1" are assumed.
+     *   MIME type {@link ContentType#TEXT_PLAIN} is assumed.
      *
      * @throws IllegalArgumentException if the string parameter is null
-     * @throws UnsupportedEncodingException if the charset specified in the CotnentType
-     *   is not supported.
      *
      * @since 4.2
      */
-    public StringEntity(final String string, final ContentType contentType)
-            throws UnsupportedEncodingException {
+    public StringEntity(final String string, final ContentType contentType) {
         super();
         if (string == null) {
             throw new IllegalArgumentException("Source string may not be null");
         }
-        String charset = contentType != null ? contentType.getCharset() : null;
+        Charset charset = contentType != null ? contentType.getCharset() : null;
         if (charset == null) {
-            charset = HTTP.DEFAULT_CONTENT_CHARSET;
+            charset = HTTP.DEF_CONTENT_CHARSET;
+        }
+        try {
+            this.content = string.getBytes(charset.name());
+        } catch (UnsupportedEncodingException ex) {
+            // should never happen
+            throw new UnsupportedCharsetException(charset.name());
         }
-        this.content = string.getBytes(charset);
         if (contentType != null) {
             setContentType(contentType.toString());
         }
@@ -138,7 +87,7 @@ public class StringEntity extends Abstra
      * @param mimeType mime type to be used. May be {@code null}, in which case the default
      *   is {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain"
      * @param charset character set to be used. May be {@code null}, in which case the default
-     *   is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
+     *   is {@link HTTP#DEF_CONTENT_CHARSET} i.e. "ISO-8859-1"
      *
      * @since 4.1
      * @throws IllegalArgumentException if the string parameter is null
@@ -164,24 +113,23 @@ public class StringEntity extends Abstra
 
     /**
      * Creates a StringEntity with the specified content and charset. The mime type defaults
-     * to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * to "text/plain".
      *
      * @param string content to be used. Not {@code null}.
      * @param charset character set to be used. May be {@code null}, in which case the default
-     *   is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
+     *   is {@link HTTP#DEF_CONTENT_CHARSET} is assumed
      *
      * @throws IllegalArgumentException if the string parameter is null
      * @throws UnsupportedEncodingException if the charset is not supported.
      */
     public StringEntity(final String string, final String charset)
             throws UnsupportedEncodingException {
-        this(string, ContentType.create(HTTP.PLAIN_TEXT_TYPE, charset));
+        this(string, ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), charset));
     }
 
     /**
-     * Creates a StringEntity with the specified content and charset. The charset defaults to
-     * {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1". The mime type defaults to
-     * {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * Creates a StringEntity with the specified content. The content type defaults to
+     * {@link ContentType#TEXT_PLAIN}.
      *
      * @param string content to be used. Not {@code null}.
      *

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java Tue Apr 17 21:47:26 2012
@@ -60,7 +60,7 @@ public final class HttpProtocolParams im
         String charset = (String) params.getParameter
             (CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
         if (charset == null) {
-            charset = HTTP.DEFAULT_PROTOCOL_CHARSET;
+            charset = HTTP.DEF_PROTOCOL_CHARSET.name();
         }
         return charset;
     }
@@ -92,7 +92,7 @@ public final class HttpProtocolParams im
         String charset = (String) params.getParameter
             (CoreProtocolPNames.HTTP_CONTENT_CHARSET);
         if (charset == null) {
-            charset = HTTP.DEFAULT_CONTENT_CHARSET;
+            charset = HTTP.DEF_CONTENT_CHARSET.name();
         }
         return charset;
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HTTP.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HTTP.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HTTP.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HTTP.java Tue Apr 17 21:47:26 2012
@@ -27,7 +27,9 @@
 
 package org.apache.http.protocol;
 
-import org.apache.http.entity.ContentType;
+import java.nio.charset.Charset;
+
+import org.apache.http.Consts;
 
 /**
  * Constants and static helpers related to the HTTP protocol.
@@ -64,24 +66,31 @@ public final class HTTP {
     public static final String CHUNK_CODING = "chunked";
     public static final String IDENTITY_CODING = "identity";
 
-    /** Common charset definitions */
+    public static final Charset DEF_CONTENT_CHARSET = Consts.ISO_8859_1;
+    public static final Charset DEF_PROTOCOL_CHARSET = Consts.ASCII;
+    
+    @Deprecated
     public static final String UTF_8 = "UTF-8";
+    @Deprecated
     public static final String UTF_16 = "UTF-16";
+    @Deprecated
     public static final String US_ASCII = "US-ASCII";
+    @Deprecated
     public static final String ASCII = "ASCII";
+    @Deprecated
     public static final String ISO_8859_1 = "ISO-8859-1";
-
-    /** Default charsets */
-    public static final String DEFAULT_CONTENT_CHARSET = ISO_8859_1;
-    public static final String DEFAULT_PROTOCOL_CHARSET = US_ASCII;
-
-    /** Content type definitions */
+    @Deprecated
+    public static final String DEFAULT_CONTENT_CHARSET = Consts.ISO_8859_1.name();
+    @Deprecated
+    public static final String DEFAULT_PROTOCOL_CHARSET = Consts.ASCII.name();
+    @Deprecated
     public final static String OCTET_STREAM_TYPE = "application/octet-stream";
+    @Deprecated
     public final static String PLAIN_TEXT_TYPE = "text/plain";
+    @Deprecated
     public final static String CHARSET_PARAM = "; charset=";
-
-    /** Default content type */
-    public final static String DEFAULT_CONTENT_TYPE = ContentType.APPLICATION_OCTET_STREAM.toString();
+    @Deprecated
+    public final static String DEFAULT_CONTENT_TYPE = OCTET_STREAM_TYPE;
 
     public static boolean isWhitespace(char ch) {
         return ch == SP || ch == HT || ch == CR || ch == LF;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java Tue Apr 17 21:47:26 2012
@@ -28,7 +28,7 @@ package org.apache.http.util;
 
 import java.io.UnsupportedEncodingException;
 
-import org.apache.http.protocol.HTTP;
+import org.apache.http.Consts;
 
 /**
  * The home for utility methods that handle various encoding tasks.
@@ -126,7 +126,7 @@ public final class EncodingUtils {
         }
 
         try {
-            return data.getBytes(HTTP.US_ASCII);
+            return data.getBytes(Consts.ASCII.name());
         } catch (UnsupportedEncodingException e) {
             throw new Error("HttpClient requires ASCII support");
         }
@@ -149,7 +149,7 @@ public final class EncodingUtils {
         }
 
         try {
-            return new String(data, offset, length, HTTP.US_ASCII);
+            return new String(data, offset, length, Consts.ASCII.name());
         } catch (UnsupportedEncodingException e) {
             throw new Error("HttpClient requires ASCII support");
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Tue Apr 17 21:47:26 2012
@@ -31,6 +31,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.Charset;
 
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
@@ -192,7 +193,7 @@ public final class EntityUtils {
      * @throws IOException if an error occurs reading the input stream
      */
     public static String toString(
-            final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
+            final HttpEntity entity, final Charset defaultCharset) throws IOException, ParseException {
         if (entity == null) {
             throw new IllegalArgumentException("HTTP entity may not be null");
         }
@@ -209,12 +210,12 @@ public final class EntityUtils {
                 i = 4096;
             }
             ContentType contentType = ContentType.getOrDefault(entity);
-            String charset = contentType.getCharset();
+            Charset charset = contentType.getCharset();
             if (charset == null) {
                 charset = defaultCharset;
             }
             if (charset == null) {
-                charset = HTTP.DEFAULT_CONTENT_CHARSET;
+                charset = HTTP.DEF_CONTENT_CHARSET;
             }
             Reader reader = new InputStreamReader(instream, charset);
             CharArrayBuffer buffer = new CharArrayBuffer(i);
@@ -230,6 +231,24 @@ public final class EntityUtils {
     }
 
     /**
+     * Get the entity content as a String, using the provided default character set
+     * if none is found in the entity.
+     * If defaultCharset is null, the default "ISO-8859-1" is used.
+     *
+     * @param entity must not be null
+     * @param defaultCharset character set to be applied if none found in the entity
+     * @return the entity content as a String. May be null if
+     *   {@link HttpEntity#getContent()} is null.
+     * @throws ParseException if header elements cannot be parsed
+     * @throws IllegalArgumentException if entity is null or if content length > Integer.MAX_VALUE
+     * @throws IOException if an error occurs reading the input stream
+     */
+    public static String toString(
+            final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
+        return toString(entity, Charset.forName(defaultCharset));
+    }
+
+    /**
      * Read the contents of an entity and return it as a String.
      * The content is converted using the character set from the entity (if any),
      * failing that, "ISO-8859-1" is used.
@@ -242,7 +261,7 @@ public final class EntityUtils {
      */
     public static String toString(final HttpEntity entity)
         throws IOException, ParseException {
-        return toString(entity, null);
+        return toString(entity, (Charset)null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java Tue Apr 17 21:47:26 2012
@@ -42,13 +42,13 @@ public class TestAbstractHttpEntity {
     @Test
     public void testContentType() throws Exception {
         BasicHttpEntity httpentity = new BasicHttpEntity();
-        httpentity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, HTTP.PLAIN_TEXT_TYPE));
+        httpentity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "blah"));
         Assert.assertEquals(HTTP.CONTENT_TYPE, httpentity.getContentType().getName());
-        Assert.assertEquals(HTTP.PLAIN_TEXT_TYPE, httpentity.getContentType().getValue());
+        Assert.assertEquals("blah", httpentity.getContentType().getValue());
 
-        httpentity.setContentType(HTTP.PLAIN_TEXT_TYPE);
+        httpentity.setContentType("blah");
         Assert.assertEquals(HTTP.CONTENT_TYPE, httpentity.getContentType().getName());
-        Assert.assertEquals(HTTP.PLAIN_TEXT_TYPE, httpentity.getContentType().getValue());
+        Assert.assertEquals("blah", httpentity.getContentType().getValue());
 
         httpentity.setContentType((Header)null);
         Assert.assertNull(httpentity.getContentType());

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java Tue Apr 17 21:47:26 2012
@@ -31,7 +31,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
-import org.apache.http.protocol.HTTP;
+import org.apache.http.Consts;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -44,7 +44,7 @@ public class TestBasicHttpEntity {
     @Test
     public void testBasics() throws Exception {
 
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         InputStream content = new ByteArrayInputStream(bytes);
         BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(content);
@@ -57,7 +57,7 @@ public class TestBasicHttpEntity {
 
     @Test
     public void testContent() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         InputStream content = new ByteArrayInputStream(bytes);
         BasicHttpEntity httpentity = new BasicHttpEntity();
         try {
@@ -80,7 +80,7 @@ public class TestBasicHttpEntity {
 
     @Test
     public void testWriteTo() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         InputStream content = new ByteArrayInputStream(bytes);
         BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(content);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java Tue Apr 17 21:47:26 2012
@@ -30,7 +30,7 @@ package org.apache.http.entity;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
-import org.apache.http.protocol.HTTP;
+import org.apache.http.Consts;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -42,7 +42,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testBufferingEntity() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1);
         BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
         Assert.assertEquals(bytes.length, bufentity.getContentLength());
@@ -57,7 +57,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWrappingEntity() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
         httpentity.setChunked(true);
         BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
@@ -83,7 +83,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWriteToBuffered() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1);
         BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
 
@@ -115,7 +115,7 @@ public class TestBufferedHttpEntity {
 
     @Test
     public void testWriteToWrapped() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
         BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java Tue Apr 17 21:47:26 2012
@@ -29,7 +29,7 @@ package org.apache.http.entity;
 
 import java.io.ByteArrayOutputStream;
 
-import org.apache.http.protocol.HTTP;
+import org.apache.http.Consts;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -41,7 +41,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testBasics() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
 
         Assert.assertEquals(bytes.length, httpentity.getContentLength());
@@ -52,7 +52,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testBasicOffLen() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes, 8, 7);
 
         Assert.assertEquals(7, httpentity.getContentLength());
@@ -68,25 +68,25 @@ public class TestByteArrayEntity {
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadLen() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         new ByteArrayEntity(bytes, 0, bytes.length + 1);
     }
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadOff1() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         new ByteArrayEntity(bytes, -1, bytes.length);
     }
 
     @Test(expected=IndexOutOfBoundsException.class)
     public void testIllegalConstructorBadOff2() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         new ByteArrayEntity(bytes, bytes.length + 1, bytes.length);
     }
 
     @Test
     public void testWriteTo() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -117,7 +117,7 @@ public class TestByteArrayEntity {
 
     @Test
     public void testWriteToOffLen() throws Exception {
-        byte[] bytes = "Message content".getBytes(HTTP.US_ASCII);
+        byte[] bytes = "Message content".getBytes(Consts.ASCII.name());
         int off = 8;
         int len = 7;
         ByteArrayEntity httpentity = new ByteArrayEntity(bytes, off, len);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestContentType.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestContentType.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestContentType.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestContentType.java Tue Apr 17 21:47:26 2012
@@ -42,35 +42,35 @@ public class TestContentType {
 
     @Test
     public void testBasis() throws Exception {
-        ContentType contentType = ContentType.create("text/plain", "ascii");
+        ContentType contentType = ContentType.create("text/plain", "US-ASCII");
         Assert.assertEquals("text/plain", contentType.getMimeType());
-        Assert.assertEquals("ascii", contentType.getCharset());
-        Assert.assertEquals("text/plain; charset=ascii", contentType.toString());
+        Assert.assertEquals("US-ASCII", contentType.getCharset().name());
+        Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
     }
 
     @Test
     public void testLowCaseText() throws Exception {
-        ContentType contentType = ContentType.create("Text/Plain", "ASCII");
+        ContentType contentType = ContentType.create("Text/Plain", "ascii");
         Assert.assertEquals("text/plain", contentType.getMimeType());
-        Assert.assertEquals("ascii", contentType.getCharset());
+        Assert.assertEquals("US-ASCII", contentType.getCharset().name());
     }
 
     @Test
     public void testCreateInvalidInput() throws Exception {
         try {
-            ContentType.create(null, null);
+            ContentType.create(null, (String) null);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            ContentType.create("  ", null);
+            ContentType.create("  ", (String) null);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            ContentType.create("stuff;", null);
+            ContentType.create("stuff;", (String) null);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -87,8 +87,8 @@ public class TestContentType {
     public void testParse() throws Exception {
         ContentType contentType = ContentType.parse("text/plain; charset=\"ascii\"");
         Assert.assertEquals("text/plain", contentType.getMimeType());
-        Assert.assertEquals("ascii", contentType.getCharset());
-        Assert.assertEquals("text/plain; charset=ascii", contentType.toString());
+        Assert.assertEquals("US-ASCII", contentType.getCharset().name());
+        Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
     }
 
     @Test
@@ -126,7 +126,7 @@ public class TestContentType {
         ContentType contentType = ContentType.get(httpentity);
         Assert.assertNotNull(contentType);
         Assert.assertEquals("text/plain", contentType.getMimeType());
-        Assert.assertEquals("utf-8", contentType.getCharset());
+        Assert.assertEquals("UTF-8", contentType.getCharset().name());
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java Tue Apr 17 21:47:26 2012
@@ -32,7 +32,6 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 
-import org.apache.http.protocol.HTTP;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -46,8 +45,7 @@ public class TestFileEntity {
     public void testBasics() throws Exception {
         File tmpfile = File.createTempFile("testfile", ".txt");
         tmpfile.deleteOnExit();
-        FileEntity httpentity = new FileEntity(tmpfile,
-                ContentType.create("text/plain", HTTP.ISO_8859_1));
+        FileEntity httpentity = new FileEntity(tmpfile, ContentType.TEXT_PLAIN);
 
         Assert.assertEquals(tmpfile.length(), httpentity.getContentLength());
         final InputStream content = httpentity.getContent();
@@ -63,7 +61,7 @@ public class TestFileEntity {
     @Test
     public void testIllegalConstructor() throws Exception {
         try {
-            new FileEntity(null, ContentType.create("text/plain", HTTP.ISO_8859_1));
+            new FileEntity(null, ContentType.TEXT_PLAIN);
             Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -82,8 +80,7 @@ public class TestFileEntity {
         outstream.write(3);
         outstream.close();
 
-        FileEntity httpentity = new FileEntity(tmpfile,
-                ContentType.create("text/plain", HTTP.ISO_8859_1));
+        FileEntity httpentity = new FileEntity(tmpfile, ContentType.TEXT_PLAIN);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         httpentity.writeTo(out);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java?rev=1327298&r1=1327297&r2=1327298&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java Tue Apr 17 21:47:26 2012
@@ -29,6 +29,7 @@ package org.apache.http.entity;
 
 import java.io.ByteArrayOutputStream;
 
+import org.apache.http.Consts;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
@@ -43,8 +44,7 @@ public class TestHttpEntityWrapper {
     @Test
     public void testBasics() throws Exception {
         String s = "Message content";
-        StringEntity httpentity = new StringEntity(s, HTTP.ISO_8859_1);
-        httpentity.setContentType(HTTP.PLAIN_TEXT_TYPE);
+        StringEntity httpentity = new StringEntity(s, ContentType.TEXT_PLAIN);
         httpentity.setContentEncoding(HTTP.IDENTITY_CODING);
         HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity);
 
@@ -70,7 +70,7 @@ public class TestHttpEntityWrapper {
     @Test
     public void testWriteTo() throws Exception {
         String s = "Message content";
-        byte[] bytes = s.getBytes(HTTP.ISO_8859_1);
+        byte[] bytes = s.getBytes(Consts.ISO_8859_1.name());
         StringEntity httpentity = new StringEntity(s);
         HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity);
 



Mime
View raw message