hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1334436 - in /httpcomponents/httpclient/trunk: ./ fluent-hc/src/examples/org/apache/http/client/fluent/ fluent-hc/src/main/java/org/apache/http/client/fluent/ httpclient/src/examples/org/apache/http/examples/client/ httpclient/src/main/jav...
Date Sat, 05 May 2012 15:53:46 GMT
Author: olegk
Date: Sat May  5 15:53:45 2012
New Revision: 1334436

URL: http://svn.apache.org/viewvc?rev=1334436&view=rev
Log:
Upgraded to HttpCore 4.2; Fixed compile errors caused by API breakage (HTTPCLIENT-1189)

Modified:
    httpcomponents/httpclient/trunk/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
    httpcomponents/httpclient/trunk/pom.xml

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
Sat May  5 15:53:45 2012
@@ -27,6 +27,7 @@
 package org.apache.http.client.fluent;
 
 import java.io.IOException;
+import java.nio.charset.Charset;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -71,11 +72,11 @@ public class FluentResponseHandling {
                     if (!contentType.equals(ContentType.APPLICATION_XML)) {
                         throw new ClientProtocolException("Unexpected content type:" + contentType);
                     }
-                    String charset = contentType.getCharset();
+                    Charset charset = contentType.getCharset();
                     if (charset == null) {
-                        charset = HTTP.DEFAULT_CONTENT_CHARSET;
+                        charset = HTTP.DEF_CONTENT_CHARSET;
                     }
-                    return docBuilder.parse(entity.getContent(), charset);
+                    return docBuilder.parse(entity.getContent(), charset.name());
                 } catch (ParserConfigurationException ex) {
                     throw new IllegalStateException(ex);
                 } catch (SAXException ex) {

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
Sat May  5 15:53:45 2012
@@ -29,6 +29,7 @@ package org.apache.http.client.fluent;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 import org.apache.http.entity.ContentType;
 import org.apache.http.protocol.HTTP;
@@ -55,12 +56,12 @@ public class Content {
     }
 
     public String asString() {
-        String charset = this.type.getCharset();
+        Charset charset = this.type.getCharset();
         if (charset == null) {
-            charset = HTTP.DEFAULT_CONTENT_TYPE;
+            charset = HTTP.DEF_CONTENT_CHARSET;
         }
         try {
-            return new String(this.raw, charset);
+            return new String(this.raw, charset.name());
         } catch (UnsupportedEncodingException ex) {
             return new String(this.raw);
         }

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
Sat May  5 15:53:45 2012
@@ -29,8 +29,8 @@ package org.apache.http.client.fluent;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
 import java.net.URI;
+import java.nio.charset.Charset;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
@@ -266,24 +266,20 @@ public class Request {
         return this;
     }
 
-    public Request bodyForm(final Iterable <? extends NameValuePair> formParams, final
String charset) {
-        try {
-            return body(new UrlEncodedFormEntity(formParams));
-        } catch (UnsupportedEncodingException ex) {
-            throw new IllegalArgumentException(ex);
-        }
+    public Request bodyForm(final Iterable <? extends NameValuePair> formParams, final
Charset charset) {
+        return body(new UrlEncodedFormEntity(formParams, charset));
     }
 
     public Request bodyForm(final Iterable <? extends NameValuePair> formParams) {
-        return bodyForm(formParams, HTTP.DEFAULT_CONTENT_CHARSET);
+        return bodyForm(formParams, HTTP.DEF_CONTENT_CHARSET);
     }
 
     public Request bodyForm(final NameValuePair... formParams) {
-        return bodyForm(Arrays.asList(formParams), HTTP.DEFAULT_CONTENT_CHARSET);
+        return bodyForm(Arrays.asList(formParams), HTTP.DEF_CONTENT_CHARSET);
     }
 
     public Request bodyString(final String s, final ContentType contentType) {
-        return body(StringEntity.create(s, contentType));
+        return body(new StringEntity(s, contentType));
     }
 
     public Request bodyFile(final File file, final ContentType contentType) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
Sat May  5 15:53:45 2012
@@ -28,6 +28,8 @@ package org.apache.http.examples.client;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
@@ -37,7 +39,6 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.cookie.Cookie;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -77,7 +78,7 @@ public class ClientFormLogin {
             nvps.add(new BasicNameValuePair("IDToken1", "username"));
             nvps.add(new BasicNameValuePair("IDToken2", "password"));
 
-            httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
+            httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
 
             response = httpclient.execute(httpost);
             entity = response.getEntity();

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
Sat May  5 15:53:45 2012
@@ -51,16 +51,15 @@ public class ProxyTunnelDemo {
         UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user",
"pwd");
         Socket socket = proxyClient.tunnel(proxy, target, credentials);
         try {
-            Writer out = new OutputStreamWriter(socket.getOutputStream(),
-                    HTTP.DEFAULT_CONTENT_CHARSET);
+            Writer out = new OutputStreamWriter(socket.getOutputStream(), HTTP.DEF_CONTENT_CHARSET);
             out.write("GET / HTTP/1.1\r\n");
             out.write("Host: " + target.toHostString() + "\r\n");
             out.write("Agent: whatever\r\n");
             out.write("Connection: close\r\n");
             out.write("\r\n");
             out.flush();
-            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream(),
-                    HTTP.DEFAULT_CONTENT_CHARSET));
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(socket.getInputStream(), HTTP.DEF_CONTENT_CHARSET));
             String line = null;
             while ((line = in.readLine()) != null) {
                 System.out.println(line);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
Sat May  5 15:53:45 2012
@@ -61,7 +61,7 @@ public final class AuthParams {
         String charset = (String) params.getParameter
             (AuthPNames.CREDENTIAL_CHARSET);
         if (charset == null) {
-            charset = HTTP.DEFAULT_PROTOCOL_CHARSET;
+            charset = HTTP.DEF_PROTOCOL_CHARSET.name();
         }
         return charset;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
Sat May  5 15:53:45 2012
@@ -27,6 +27,7 @@
 package org.apache.http.client.entity;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.util.List;
 
 import org.apache.http.annotation.NotThreadSafe;
@@ -46,24 +47,6 @@ import org.apache.http.protocol.HTTP;
 @NotThreadSafe // AbstractHttpEntity is not thread-safe
 public class UrlEncodedFormEntity extends StringEntity {
 
-    public static UrlEncodedFormEntity create(
-            final Iterable <? extends NameValuePair> parameters, final String charset)
{
-        try {
-            return new UrlEncodedFormEntity(parameters, charset);
-        } catch (UnsupportedEncodingException ex) {
-            throw new IllegalArgumentException(ex.getMessage(), ex);
-        }
-    }
-    
-    public static UrlEncodedFormEntity create(
-            final Iterable <? extends NameValuePair> parameters) {
-        try {
-            return new UrlEncodedFormEntity(parameters, null);
-        } catch (UnsupportedEncodingException ex) {
-            throw new IllegalArgumentException(ex.getMessage(), ex);
-        }
-    }
-
     /**
      * Constructs a new {@link UrlEncodedFormEntity} with the list
      * of parameters in the specified encoding.
@@ -76,7 +59,7 @@ public class UrlEncodedFormEntity extend
         final List <? extends NameValuePair> parameters,
         final String charset) throws UnsupportedEncodingException {
         super(URLEncodedUtils.format(parameters, 
-                charset != null ? charset : HTTP.DEFAULT_CONTENT_CHARSET), 
+                charset != null ? charset : HTTP.DEF_CONTENT_CHARSET.name()), 
                 ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset));
     }
 
@@ -92,9 +75,9 @@ public class UrlEncodedFormEntity extend
      */
     public UrlEncodedFormEntity (
         final Iterable <? extends NameValuePair> parameters,
-        final String charset) throws UnsupportedEncodingException {
+        final Charset charset) {
         super(URLEncodedUtils.format(parameters, 
-                charset != null ? charset : HTTP.DEFAULT_CONTENT_CHARSET), 
+                charset != null ? charset : HTTP.DEF_CONTENT_CHARSET), 
                 ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset));
     }
 
@@ -107,7 +90,7 @@ public class UrlEncodedFormEntity extend
      */
     public UrlEncodedFormEntity (
         final List <? extends NameValuePair> parameters) throws UnsupportedEncodingException
{
-        this(parameters, null);
+        this(parameters, (Charset) null);
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
Sat May  5 15:53:45 2012
@@ -28,13 +28,14 @@ package org.apache.http.client.utils;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.http.Consts;
 import org.apache.http.NameValuePair;
 import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HTTP;
 
 /**
  * @since 4.2
@@ -66,18 +67,18 @@ public class URIBuilder {
         digestURI(uri);
     }
 
-    private List <NameValuePair> parseQuery(final String query, final String encoding)
{
+    private List <NameValuePair> parseQuery(final String query, final Charset charset)
{
         if (query != null && query.length() > 0) {
-            return URLEncodedUtils.parse(query, encoding);
+            return URLEncodedUtils.parse(query, charset);
         }
         return null;
     }
 
-    private String formatQuery(final List<NameValuePair> parameters, final String encoding)
{
+    private String formatQuery(final List<NameValuePair> parameters, final Charset
charset) {
         if (parameters == null) {
             return null;
         }
-        return URLEncodedUtils.format(parameters, encoding);
+        return URLEncodedUtils.format(parameters, charset);
     }
 
     /**
@@ -88,11 +89,11 @@ public class URIBuilder {
             return new URI(this.scheme, this.schemeSpecificPart, this.fragment);
         } else if (this.authority != null) {
             return new URI(this.scheme, this.authority,
-                    this.path, formatQuery(this.queryParams, HTTP.UTF_8), this.fragment);
+                    this.path, formatQuery(this.queryParams, Consts.UTF_8), this.fragment);
 
         } else {
             return new URI(this.scheme, this.userInfo, this.host, this.port,
-                    this.path, formatQuery(this.queryParams, HTTP.UTF_8), this.fragment);
+                    this.path, formatQuery(this.queryParams, Consts.UTF_8), this.fragment);
         }
     }
 
@@ -104,7 +105,7 @@ public class URIBuilder {
         this.port = uri.getPort();
         this.userInfo = uri.getUserInfo();
         this.path = uri.getPath();
-        this.queryParams = parseQuery(uri.getRawQuery(), HTTP.UTF_8);
+        this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
         this.fragment = uri.getFragment();
     }
 
@@ -175,7 +176,7 @@ public class URIBuilder {
      * Set URI query.
      */
     public URIBuilder setQuery(final String query) {
-        this.queryParams = parseQuery(query, HTTP.UTF_8);
+        this.queryParams = parseQuery(query, Consts.UTF_8);
         this.schemeSpecificPart = null;
         return this;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
Sat May  5 15:53:45 2012
@@ -32,6 +32,7 @@ import java.io.UnsupportedEncodingExcept
 import java.net.URI;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -40,6 +41,7 @@ import java.util.Scanner;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.entity.ContentType;
 
+import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
@@ -79,7 +81,10 @@ public class URLEncodedUtils {
     public static List <NameValuePair> parse (final URI uri, final String encoding)
{
         final String query = uri.getRawQuery();
         if (query != null && query.length() > 0) {
-            return parse(query, encoding);
+            List<NameValuePair> result = new ArrayList<NameValuePair>();
+            Scanner scanner = new Scanner(query);
+            parse(result, scanner, encoding);
+            return result;
         } else {
             return Collections.emptyList();
         }
@@ -99,17 +104,18 @@ public class URLEncodedUtils {
      */
     public static List <NameValuePair> parse (
             final HttpEntity entity) throws IOException {
-        List <NameValuePair> result = new ArrayList<NameValuePair>();
         ContentType contentType = ContentType.get(entity);
         if (contentType != null && contentType.getMimeType().equalsIgnoreCase(CONTENT_TYPE))
{
-            String content = EntityUtils.toString(entity, HTTP.ASCII);
+            String content = EntityUtils.toString(entity, Consts.ASCII);
             if (content != null && content.length() > 0) {
-                Scanner scanner = new Scanner(entity.getContent(), HTTP.ASCII);
-                parse(result, scanner, contentType.getCharset() != null ?
-                        contentType.getCharset() : HTTP.DEFAULT_CONTENT_CHARSET);
+                Charset charset = contentType != null ? contentType.getCharset() : null;
+                if (charset == null) {
+                    charset = HTTP.DEF_CONTENT_CHARSET;
+                }
+                return parse(content, charset);
             }
         }
-        return result;
+        return Collections.emptyList();
     }
 
     /**
@@ -178,7 +184,7 @@ public class URLEncodedUtils {
      *
      * @since 4.2
      */
-    public static List<NameValuePair> parse (final String s, final String charset)
{
+    public static List<NameValuePair> parse (final String s, final Charset charset)
{
         if (s == null) {
             return Collections.emptyList();
         }
@@ -235,7 +241,7 @@ public class URLEncodedUtils {
      */
     public static String format (
             final Iterable<? extends NameValuePair> parameters,
-            final String charset) {
+            final Charset charset) {
         final StringBuilder result = new StringBuilder();
         for (final NameValuePair parameter : parameters) {
             final String encodedName = encode(parameter.getName(), charset);
@@ -257,11 +263,18 @@ public class URLEncodedUtils {
             return null;
         }
         try {
-            return URLDecoder.decode(content,
-                    charset != null ? charset : HTTP.DEFAULT_CONTENT_CHARSET);
-        } catch (UnsupportedEncodingException problem) {
-            throw new IllegalArgumentException(problem);
+            return URLDecoder.decode(content, 
+                    charset != null ? charset : HTTP.DEF_CONTENT_CHARSET.name());
+        } catch (UnsupportedEncodingException ex) {
+            throw new IllegalArgumentException(ex);
+        }
+    }
+
+    private static String decode (final String content, final Charset charset) {
+        if (content == null) {
+            return null;
         }
+        return decode(content, charset != null ? charset.name() : null);
     }
 
     private static String encode (final String content, final String charset) {
@@ -269,11 +282,18 @@ public class URLEncodedUtils {
             return null;
         }
         try {
-            return URLEncoder.encode(content,
-                    charset != null ? charset : HTTP.DEFAULT_CONTENT_CHARSET);
-        } catch (UnsupportedEncodingException problem) {
-            throw new IllegalArgumentException(problem);
+            return URLEncoder.encode(content, 
+                    charset != null ? charset : HTTP.DEF_CONTENT_CHARSET.name());
+        } catch (UnsupportedEncodingException ex) {
+            throw new IllegalArgumentException(ex);
+        }
+    }
+
+    private static String encode (final String content, final Charset charset) {
+        if (content == null) {
+            return null;
         }
+        return encode(content, charset != null ? charset.name() : null);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
Sat May  5 15:53:45 2012
@@ -172,7 +172,7 @@ public class DefaultHttpClient extends A
      */
     public static void setDefaultHttpParams(HttpParams params) {
         HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-        HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
+        HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
         HttpConnectionParams.setTcpNoDelay(params, true);
         HttpConnectionParams.setSocketBufferSize(params, 8192);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
Sat May  5 15:53:45 2012
@@ -28,12 +28,12 @@ package org.apache.http.impl.conn;
 
 import java.io.IOException;
 
+import org.apache.http.Consts;
 import org.apache.http.annotation.Immutable;
 
 import org.apache.http.io.EofSensor;
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -67,7 +67,7 @@ public class LoggingSessionInputBuffer i
         this.in = in;
         this.eofSensor = in instanceof EofSensor ? (EofSensor) in : null;
         this.wire = wire;
-        this.charset = charset != null ? charset : HTTP.ASCII;
+        this.charset = charset != null ? charset : Consts.ASCII.name();
     }
 
     public LoggingSessionInputBuffer(final SessionInputBuffer in, final Wire wire) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
Sat May  5 15:53:45 2012
@@ -28,11 +28,11 @@ package org.apache.http.impl.conn;
 
 import java.io.IOException;
 
+import org.apache.http.Consts;
 import org.apache.http.annotation.Immutable;
 
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -63,7 +63,7 @@ public class LoggingSessionOutputBuffer 
         super();
         this.out = out;
         this.wire = wire;
-        this.charset = charset != null ? charset : HTTP.ASCII;
+        this.charset = charset != null ? charset : Consts.ASCII.name();
     }
 
     public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
Sat May  5 15:53:45 2012
@@ -31,6 +31,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.http.Consts;
 import org.apache.http.NameValuePair;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
@@ -132,13 +133,13 @@ public class TestURLEncodedUtils {
         parameters.add(new BasicNameValuePair("russian", ru_hello));
         parameters.add(new BasicNameValuePair("swiss", ch_hello));
 
-        String s = URLEncodedUtils.format(parameters, HTTP.UTF_8);
+        String s = URLEncodedUtils.format(parameters, Consts.UTF_8);
 
         Assert.assertEquals("russian=%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82"
+
                 "&swiss=Gr%C3%BCezi_z%C3%A4m%C3%A4", s);
 
         StringEntity entity = new StringEntity(s, ContentType.create(
-                URLEncodedUtils.CONTENT_TYPE, HTTP.UTF_8));
+                URLEncodedUtils.CONTENT_TYPE, Consts.UTF_8));
         List <NameValuePair> result = URLEncodedUtils.parse(entity);
         Assert.assertEquals(2, result.size());
         assertNameValuePair(result.get(0), "russian", ru_hello);
@@ -153,9 +154,9 @@ public class TestURLEncodedUtils {
         parameters.add(new BasicNameValuePair("russian", ru_hello));
         parameters.add(new BasicNameValuePair("swiss", ch_hello));
 
-        String s = URLEncodedUtils.format(parameters, HTTP.UTF_8);
+        String s = URLEncodedUtils.format(parameters, Consts.UTF_8);
 
-        List <NameValuePair> result = URLEncodedUtils.parse(s, HTTP.UTF_8);
+        List <NameValuePair> result = URLEncodedUtils.parse(s, Consts.UTF_8);
         Assert.assertEquals(2, result.size());
         assertNameValuePair(result.get(0), "russian", ru_hello);
         assertNameValuePair(result.get(1), "swiss", ch_hello);
@@ -169,12 +170,12 @@ public class TestURLEncodedUtils {
         parameters.add(new BasicNameValuePair("english", us_hello));
         parameters.add(new BasicNameValuePair("swiss", ch_hello));
 
-        String s = URLEncodedUtils.format(parameters, HTTP.DEFAULT_CONTENT_CHARSET);
+        String s = URLEncodedUtils.format(parameters, HTTP.DEF_CONTENT_CHARSET);
 
         Assert.assertEquals("english=hi+there&swiss=Gr%FCezi_z%E4m%E4", s);
 
         StringEntity entity = new StringEntity(s, ContentType.create(
-                URLEncodedUtils.CONTENT_TYPE, null));
+                URLEncodedUtils.CONTENT_TYPE, HTTP.DEF_CONTENT_CHARSET));
         List <NameValuePair> result = URLEncodedUtils.parse(entity);
         Assert.assertEquals(2, result.size());
         assertNameValuePair(result.get(0), "english", us_hello);
@@ -198,46 +199,46 @@ public class TestURLEncodedUtils {
     @Test
     public void testFormat () throws Exception {
         final List <NameValuePair> params = new ArrayList <NameValuePair>();
-        Assert.assertEquals(0, URLEncodedUtils.format(params, null).length());
+        Assert.assertEquals(0, URLEncodedUtils.format(params, Consts.ASCII).length());
 
         params.clear();
         params.add(new BasicNameValuePair("Name0", null));
-        Assert.assertEquals("Name0", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name0", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name1", "Value1"));
-        Assert.assertEquals("Name1=Value1", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name1=Value1", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name2", ""));
-        Assert.assertEquals("Name2=", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name2=", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value 4!"));
-        Assert.assertEquals("Name4=Value+4%21", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value+4%21", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value+4!"));
-        Assert.assertEquals("Name4=Value%2B4%21", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value%2B4%21", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value 4! !4"));
-        Assert.assertEquals("Name4=Value+4%21+%214", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value+4%21+%214", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name5", "aaa"));
         params.add(new BasicNameValuePair("Name6", "bbb"));
-        Assert.assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name7", "aaa"));
         params.add(new BasicNameValuePair("Name7", "b,b"));
         params.add(new BasicNameValuePair("Name7", "ccc"));
-        Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params,
null));
+        Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params,
Consts.ASCII));
 
         params.clear();
         params.add(new BasicNameValuePair("Name8", "xx,  yy  ,zz"));
-        Assert.assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, Consts.ASCII));
     }
 
     private List <NameValuePair> parse (final String params, final String encoding)
{

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
Sat May  5 15:53:45 2012
@@ -543,7 +543,7 @@ public class TestDigestScheme {
                 "qop=\"auth,auth-int\"";
         Header authChallenge = new BasicHeader(AUTH.WWW_AUTH, challenge);
         HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("Post",
"/");
-        request.setEntity(new StringEntity("abc\u00e4\u00f6\u00fcabc", HTTP.DEFAULT_CONTENT_CHARSET));
+        request.setEntity(new StringEntity("abc\u00e4\u00f6\u00fcabc", HTTP.DEF_CONTENT_CHARSET));
         Credentials cred = new UsernamePasswordCredentials("username","password");
         DigestScheme authscheme = new DigestScheme();
         HttpContext context = new BasicHttpContext();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
Sat May  5 15:53:45 2012
@@ -50,7 +50,7 @@ public class TestBasicResponseHandler {
     public void testSuccessfulResponse() throws Exception {
         StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK");
         HttpResponse response = Mockito.mock(HttpResponse.class);
-        HttpEntity entity = StringEntity.create("stuff");
+        HttpEntity entity = new StringEntity("stuff");
         Mockito.when(response.getStatusLine()).thenReturn(sl);
         Mockito.when(response.getEntity()).thenReturn(entity);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
Sat May  5 15:53:45 2012
@@ -28,6 +28,7 @@ package org.apache.http.impl.client;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -53,7 +54,6 @@ import org.apache.http.localserver.Respo
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExpectationVerifier;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -96,7 +96,7 @@ public class TestClientAuthentication ex
                 response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
             } else {
                 response.setStatusCode(HttpStatus.SC_OK);
-                StringEntity entity = new StringEntity("success", HTTP.ASCII);
+                StringEntity entity = new StringEntity("success", Consts.ASCII);
                 response.setEntity(entity);
             }
         }
@@ -295,7 +295,7 @@ public class TestClientAuthentication ex
         this.httpclient.setCredentialsProvider(credsProvider);
 
         HttpPost httppost = new HttpPost("/");
-        httppost.setEntity(new StringEntity("some important stuff", HTTP.ISO_8859_1));
+        httppost.setEntity(new StringEntity("some important stuff", Consts.ASCII));
 
         HttpResponse response = this.httpclient.execute(getServerHttp(), httppost);
         HttpEntity entity = response.getEntity();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
Sat May  5 15:53:45 2012
@@ -27,6 +27,7 @@ package org.apache.http.impl.client;
 
 import java.io.IOException;
 
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
@@ -44,7 +45,6 @@ import org.apache.http.localserver.Basic
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.protocol.ResponseConnControl;
@@ -96,7 +96,7 @@ public class TestClientAuthenticationFal
                 response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
             } else {
                 response.setStatusCode(HttpStatus.SC_OK);
-                StringEntity entity = new StringEntity("success", HTTP.ASCII);
+                StringEntity entity = new StringEntity("success", Consts.ASCII);
                 response.setEntity(entity);
             }
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
Sat May  5 15:53:45 2012
@@ -28,6 +28,7 @@ package org.apache.http.impl.client;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
@@ -46,7 +47,6 @@ import org.apache.http.localserver.Local
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.protocol.ResponseConnControl;
@@ -103,7 +103,7 @@ public class TestClientReauthentication 
                     response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
                 } else {
                     response.setStatusCode(HttpStatus.SC_OK);
-                    StringEntity entity = new StringEntity("success", HTTP.ASCII);
+                    StringEntity entity = new StringEntity("success", Consts.ASCII);
                     response.setEntity(entity);
                 }
             }

Modified: httpcomponents/httpclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/pom.xml?rev=1334436&r1=1334435&r2=1334436&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Sat May  5 15:53:45 2012
@@ -67,7 +67,7 @@
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-    <httpcore.version>4.2-beta1</httpcore.version>
+    <httpcore.version>4.2</httpcore.version>
     <commons-logging.version>1.1.1</commons-logging.version>
     <commons-codec.version>1.6</commons-codec.version>
     <ehcache.version>2.2.0</ehcache.version>



Mime
View raw message