hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1568975 - in /httpcomponents/httpclient/branches/4.3.x: fluent-hc/src/examples/org/apache/http/client/fluent/ fluent-hc/src/main/java/org/apache/http/client/fluent/ httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cach...
Date Mon, 17 Feb 2014 13:16:27 GMT
Author: olegk
Date: Mon Feb 17 13:16:26 2014
New Revision: 1568975

URL: http://svn.apache.org/r1568975
Log:
Avoid using implementation classes shipped with Android in HttpMime, HC Fluent, and Caching modules

Added:
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java   (with props)
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java
      - copied, changed from r1567936, httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java   (with props)
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java   (with props)
Modified:
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
    httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
    httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java

Modified: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java Mon Feb 17 13:16:26 2014
@@ -33,6 +33,7 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.StatusLine;
@@ -40,7 +41,6 @@ import org.apache.http.client.ClientProt
 import org.apache.http.client.HttpResponseException;
 import org.apache.http.client.ResponseHandler;
 import org.apache.http.entity.ContentType;
-import org.apache.http.protocol.HTTP;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -74,7 +74,7 @@ public class FluentResponseHandling {
                     }
                     Charset charset = contentType.getCharset();
                     if (charset == null) {
-                        charset = HTTP.DEF_CONTENT_CHARSET;
+                        charset = Consts.ISO_8859_1;
                     }
                     return docBuilder.parse(entity.getContent(), charset.name());
                 } catch (ParserConfigurationException ex) {

Modified: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java Mon Feb 17 13:16:26 2014
@@ -31,8 +31,8 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 
+import org.apache.http.Consts;
 import org.apache.http.entity.ContentType;
-import org.apache.http.protocol.HTTP;
 
 public class Content {
 
@@ -58,7 +58,7 @@ public class Content {
     public String asString() {
         Charset charset = this.type.getCharset();
         if (charset == null) {
-            charset = HTTP.DEF_CONTENT_CHARSET;
+            charset = Consts.ISO_8859_1;
         }
         try {
             return new String(this.raw, charset.name());

Modified: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java Mon Feb 17 13:16:26 2014
@@ -44,7 +44,6 @@ import org.apache.http.client.ClientProt
 import org.apache.http.client.CookieStore;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
@@ -125,7 +124,8 @@ public class Executor {
     }
 
     public Executor auth(final HttpHost host, final Credentials creds) {
-        final AuthScope authScope = host != null ? new AuthScope(host) : AuthScope.ANY;
+        final AuthScope authScope = host != null ?
+                new AuthScope(host.getHostName(), host.getPort()) : AuthScope.ANY;
         return auth(authScope, creds);
     }
 
@@ -202,8 +202,7 @@ public class Executor {
         localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider);
         localContext.setAttribute(HttpClientContext.AUTH_CACHE, this.authCache);
         localContext.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
-        final HttpRequestBase httprequest = request.prepareRequest();
-        httprequest.reset();
+        final InternalHttpRequest httprequest = request.prepareRequest();
         return new Response(this.httpclient.execute(httprequest, localContext));
     }
 

Added: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java?rev=1568975&view=auto
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java (added)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java Mon Feb 17 13:16:26 2014
@@ -0,0 +1,100 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.client.fluent;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.Args;
+
+class InternalByteArrayEntity extends AbstractHttpEntity implements Cloneable {
+
+    private final byte[] b;
+    private final int off, len;
+
+    public InternalByteArrayEntity(final byte[] b, final ContentType contentType) {
+        super();
+        Args.notNull(b, "Source byte array");
+        this.b = b;
+        this.off = 0;
+        this.len = this.b.length;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
+    }
+
+    public InternalByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) {
+        super();
+        Args.notNull(b, "Source byte array");
+        if ((off < 0) || (off > b.length) || (len < 0) ||
+                ((off + len) < 0) || ((off + len) > b.length)) {
+            throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length);
+        }
+        this.b = b;
+        this.off = off;
+        this.len = len;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
+    }
+
+    public InternalByteArrayEntity(final byte[] b) {
+        this(b, null);
+    }
+
+    public InternalByteArrayEntity(final byte[] b, final int off, final int len) {
+        this(b, off, len, null);
+    }
+
+    public boolean isRepeatable() {
+        return true;
+    }
+
+    public long getContentLength() {
+        return this.len;
+    }
+
+    public InputStream getContent() {
+        return new ByteArrayInputStream(this.b, this.off, this.len);
+    }
+
+    public void writeTo(final OutputStream outstream) throws IOException {
+        Args.notNull(outstream, "Output stream");
+        outstream.write(this.b, this.off, this.len);
+        outstream.flush();
+    }
+
+    public boolean isStreaming() {
+        return false;
+    }
+
+}

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java (from r1567936, httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java?p2=httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java&p1=httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java&r1=1567936&r2=1568975&rev=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java Mon Feb 17 13:16:26 2014
@@ -24,56 +24,60 @@
  * <http://www.apache.org/>.
  *
  */
+
 package org.apache.http.client.fluent;
 
-import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
+import java.io.OutputStream;
 
+import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.ContentType;
-import org.apache.http.protocol.HTTP;
-
-public class Content {
+import org.apache.http.util.Args;
 
-    public static final Content NO_CONTENT = new Content(new byte[] {}, ContentType.DEFAULT_BINARY);
+class InternalFileEntity extends AbstractHttpEntity implements Cloneable {
 
-    private final byte[] raw;
-    private final ContentType type;
+    private final File file;
 
-    Content(final byte[] raw, final ContentType type) {
+    public InternalFileEntity(final File file, final ContentType contentType) {
         super();
-        this.raw = raw;
-        this.type = type;
+        this.file = Args.notNull(file, "File");
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
     }
 
-    public ContentType getType() {
-        return this.type;
+    public boolean isRepeatable() {
+        return true;
     }
 
-    public byte[] asBytes() {
-        return this.raw.clone();
+    public long getContentLength() {
+        return this.file.length();
     }
 
-    public String asString() {
-        Charset charset = this.type.getCharset();
-        if (charset == null) {
-            charset = HTTP.DEF_CONTENT_CHARSET;
-        }
-        try {
-            return new String(this.raw, charset.name());
-        } catch (final UnsupportedEncodingException ex) {
-            return new String(this.raw);
-        }
+    public InputStream getContent() throws IOException {
+        return new FileInputStream(this.file);
     }
 
-    public InputStream asStream() {
-        return new ByteArrayInputStream(this.raw);
+    public void writeTo(final OutputStream outstream) throws IOException {
+        Args.notNull(outstream, "Output stream");
+        final InputStream instream = new FileInputStream(this.file);
+        try {
+            final byte[] tmp = new byte[4096];
+            int l;
+            while ((l = instream.read(tmp)) != -1) {
+                outstream.write(tmp, 0, l);
+            }
+            outstream.flush();
+        } finally {
+            instream.close();
+        }
     }
 
-    @Override
-    public String toString() {
-        return asString();
+    public boolean isStreaming() {
+        return false;
     }
 
 }

Added: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java?rev=1568975&view=auto
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java (added)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java Mon Feb 17 13:16:26 2014
@@ -0,0 +1,113 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.client.fluent;
+
+import java.net.URI;
+
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.RequestLine;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.Configurable;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.message.AbstractHttpMessage;
+import org.apache.http.message.BasicRequestLine;
+import org.apache.http.util.Args;
+
+@NotThreadSafe
+class InternalHttpRequest extends AbstractHttpMessage implements HttpUriRequest, Configurable {
+
+    private final String method;
+    private ProtocolVersion version;
+    private URI uri;
+    private RequestConfig config;
+
+    InternalHttpRequest(final String method, final URI requestURI) {
+        Args.notBlank(method, "Method");
+        Args.notNull(requestURI, "Request URI");
+        this.method = method;
+        this.uri = requestURI;
+    }
+
+    public void setProtocolVersion(final ProtocolVersion version) {
+        this.version = version;
+    }
+
+    public ProtocolVersion getProtocolVersion() {
+        return version != null ? version : HttpVersion.HTTP_1_1;
+    }
+
+    public String getMethod() {
+        return this.method;
+    }
+
+    public URI getURI() {
+        return this.uri;
+    }
+
+    public void abort() throws UnsupportedOperationException {
+    }
+
+    public boolean isAborted() {
+        return false;
+    }
+
+    public RequestLine getRequestLine() {
+        final String method = getMethod();
+        final ProtocolVersion ver = getProtocolVersion();
+        final URI uri = getURI();
+        String uritext = null;
+        if (uri != null) {
+            uritext = uri.toASCIIString();
+        }
+        if (uritext == null || uritext.length() == 0) {
+            uritext = "/";
+        }
+        return new BasicRequestLine(method, uritext, ver);
+    }
+
+
+    public RequestConfig getConfig() {
+        return config;
+    }
+
+    public void setConfig(final RequestConfig config) {
+        this.config = config;
+    }
+
+    public void setURI(final URI uri) {
+        this.uri = uri;
+    }
+
+    @Override
+    public String toString() {
+        return getMethod() + " " + getURI() + " " + getProtocolVersion();
+    }
+
+}

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java?rev=1568975&view=auto
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java (added)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java Mon Feb 17 13:16:26 2014
@@ -0,0 +1,96 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.client.fluent;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.Args;
+
+class InternalInputStreamEntity extends AbstractHttpEntity {
+
+    private final InputStream content;
+    private final long length;
+
+    public InternalInputStreamEntity(final InputStream instream, final long length, final ContentType contentType) {
+        super();
+        this.content = Args.notNull(instream, "Source input stream");
+        this.length = length;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
+    }
+
+    public boolean isRepeatable() {
+        return false;
+    }
+
+    public long getContentLength() {
+        return this.length;
+    }
+
+    public InputStream getContent() throws IOException {
+        return this.content;
+    }
+
+    public void writeTo(final OutputStream outstream) throws IOException {
+        Args.notNull(outstream, "Output stream");
+        final InputStream instream = this.content;
+        try {
+            final byte[] buffer = new byte[4096];
+            int l;
+            if (this.length < 0) {
+                // consume until EOF
+                while ((l = instream.read(buffer)) != -1) {
+                    outstream.write(buffer, 0, l);
+                }
+            } else {
+                // consume no more than length
+                long remaining = this.length;
+                while (remaining > 0) {
+                    l = instream.read(buffer, 0, (int)Math.min(4096, remaining));
+                    if (l == -1) {
+                        break;
+                    }
+                    outstream.write(buffer, 0, l);
+                    remaining -= l;
+                }
+            }
+        } finally {
+            instream.close();
+        }
+    }
+
+    public boolean isStreaming() {
+        return true;
+    }
+
+}

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java Mon Feb 17 13:16:26 2014
@@ -29,14 +29,18 @@ 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.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 
+import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -45,20 +49,15 @@ import org.apache.http.HttpVersion;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.http.client.methods.HttpOptions;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.methods.HttpTrace;
-import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.client.utils.URLEncodedUtils;
 import org.apache.http.entity.ContentType;
-import org.apache.http.entity.FileEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
 import org.apache.http.protocol.HTTP;
 
 public class Request {
@@ -67,74 +66,74 @@ public class Request {
     public static final Locale DATE_LOCALE = Locale.US;
     public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT");
 
-    private final HttpRequestBase request;
+    private final InternalHttpRequest request;
     private final RequestConfig.Builder configBuilder;
 
     private SimpleDateFormat dateFormatter;
 
     public static Request Get(final URI uri) {
-        return new Request(new HttpGet(uri));
+        return new Request(HttpGet.METHOD_NAME, uri);
     }
 
     public static Request Get(final String uri) {
-        return new Request(new HttpGet(uri));
+        return new Request(HttpGet.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Head(final URI uri) {
-        return new Request(new HttpHead(uri));
+        return new Request(HttpHead.METHOD_NAME, uri);
     }
 
     public static Request Head(final String uri) {
-        return new Request(new HttpHead(uri));
+        return new Request(HttpHead.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Post(final URI uri) {
-        return new Request(new HttpPost(uri));
+        return new Request(HttpPost.METHOD_NAME, uri);
     }
 
     public static Request Post(final String uri) {
-        return new Request(new HttpPost(uri));
+        return new Request(HttpPost.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Put(final URI uri) {
-        return new Request(new HttpPut(uri));
+        return new Request(HttpPut.METHOD_NAME, uri);
     }
 
     public static Request Put(final String uri) {
-        return new Request(new HttpPut(uri));
+        return new Request(HttpPut.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Trace(final URI uri) {
-        return new Request(new HttpTrace(uri));
+        return new Request(HttpTrace.METHOD_NAME, uri);
     }
 
     public static Request Trace(final String uri) {
-        return new Request(new HttpTrace(uri));
+        return new Request(HttpTrace.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Delete(final URI uri) {
-        return new Request(new HttpDelete(uri));
+        return new Request(HttpDelete.METHOD_NAME, uri);
     }
 
     public static Request Delete(final String uri) {
-        return new Request(new HttpDelete(uri));
+        return new Request(HttpDelete.METHOD_NAME, URI.create(uri));
     }
 
     public static Request Options(final URI uri) {
-        return new Request(new HttpOptions(uri));
+        return new Request(HttpOptions.METHOD_NAME, uri);
     }
 
     public static Request Options(final String uri) {
-        return new Request(new HttpOptions(uri));
+        return new Request(HttpOptions.METHOD_NAME, URI.create(uri));
     }
 
-    Request(final HttpRequestBase request) {
+    Request(final String method, final URI requestURI) {
         super();
-        this.request = request;
+        this.request = new InternalHttpRequest(method, requestURI);
         this.configBuilder = RequestConfig.custom();
     }
 
-    HttpRequestBase prepareRequest() {
+    InternalHttpRequest prepareRequest() {
         this.request.setConfig(this.configBuilder.build());
         return this.request;
     }
@@ -304,39 +303,52 @@ public class Request {
     }
 
     public Request bodyForm(final Iterable <? extends NameValuePair> formParams, final Charset charset) {
-        return body(new UrlEncodedFormEntity(formParams, charset));
+        final List<NameValuePair> paramList = new ArrayList<NameValuePair>();
+        for (NameValuePair param : formParams) {
+            paramList.add(param);
+        }
+        final ContentType contentType = ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset);
+        final String s = URLEncodedUtils.format(paramList, charset != null ? charset.name() : null);
+        return bodyString(s, contentType);
     }
 
     public Request bodyForm(final Iterable <? extends NameValuePair> formParams) {
-        return bodyForm(formParams, HTTP.DEF_CONTENT_CHARSET);
+        return bodyForm(formParams, Consts.ISO_8859_1);
     }
 
     public Request bodyForm(final NameValuePair... formParams) {
-        return bodyForm(Arrays.asList(formParams), HTTP.DEF_CONTENT_CHARSET);
+        return bodyForm(Arrays.asList(formParams), Consts.ISO_8859_1);
     }
 
     public Request bodyString(final String s, final ContentType contentType) {
-        return body(new StringEntity(s, contentType));
+        final Charset charset = contentType != null ? contentType.getCharset() : null;
+        byte[] raw;
+        try {
+            raw = charset != null ? s.getBytes(charset.name()) : s.getBytes();
+        } catch (UnsupportedEncodingException ex) {
+            raw = s.getBytes();
+        }
+        return body(new InternalByteArrayEntity(raw, contentType));
     }
 
     public Request bodyFile(final File file, final ContentType contentType) {
-        return body(new FileEntity(file, contentType));
+        return body(new InternalFileEntity(file, contentType));
     }
 
     public Request bodyByteArray(final byte[] b) {
-        return body(new ByteArrayEntity(b));
+        return body(new InternalByteArrayEntity(b));
     }
 
     public Request bodyByteArray(final byte[] b, final int off, final int len) {
-        return body(new ByteArrayEntity(b, off, len));
+        return body(new InternalByteArrayEntity(b, off, len));
     }
 
     public Request bodyStream(final InputStream instream) {
-        return body(new InputStreamEntity(instream, -1));
+        return body(new InternalInputStreamEntity(instream, -1, null));
     }
 
     public Request bodyStream(final InputStream instream, final ContentType contentType) {
-        return body(new InputStreamEntity(instream, -1, contentType));
+        return body(new InternalInputStreamEntity(instream, -1, contentType));
     }
 
     @Override

Modified: httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java Mon Feb 17 13:16:26 2014
@@ -29,6 +29,7 @@ package org.apache.http.client.fluent;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -61,7 +62,11 @@ public class Response {
             return;
         }
         try {
-            EntityUtils.consume(this.response.getEntity());
+            final HttpEntity entity = this.response.getEntity();
+            final InputStream content = entity.getContent();
+            if (content != null) {
+                content.close();
+            }
         } catch (final Exception ignore) {
         } finally {
             this.consumed = true;
@@ -97,8 +102,11 @@ public class Response {
         try {
             final HttpEntity entity = this.response.getEntity();
             if (entity != null) {
-                this.response.setEntity(new ByteArrayEntity(EntityUtils.toByteArray(entity),
-                                ContentType.getOrDefault(entity)));
+                final ByteArrayEntity byteArrayEntity = new ByteArrayEntity(
+                        EntityUtils.toByteArray(entity));
+                final ContentType contentType = ContentType.getOrDefault(entity);
+                byteArrayEntity.setContentType(contentType.toString());
+                this.response.setEntity(byteArrayEntity);
             }
             return this.response;
         } finally {

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java Mon Feb 17 13:16:26 2014
@@ -78,7 +78,6 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
 import org.apache.http.util.VersionInfo;
 
 /**
@@ -381,7 +380,7 @@ public class CachingHttpClient implement
         } catch (final Exception t) {
             final HttpEntity entity = response.getEntity();
             try {
-                EntityUtils.consume(entity);
+                IOUtils.consume(entity);
             } catch (final Exception t2) {
                 // Log this exception. The original exception is more
                 // important and will be thrown to the caller.
@@ -399,7 +398,7 @@ public class CachingHttpClient implement
         // Handling the response was successful. Ensure that the content has
         // been fully consumed.
         final HttpEntity entity = response.getEntity();
-        EntityUtils.consume(entity);
+        IOUtils.consume(entity);
         return result;
     }
 
@@ -804,7 +803,7 @@ public class CachingHttpClient implement
         final HttpCacheEntry matchedEntry = matchingVariant.getEntry();
 
         if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) {
-            EntityUtils.consume(backendResponse.getEntity());
+            IOUtils.consume(backendResponse.getEntity());
             return retryRequestUnconditionally(target, request, context,
                     matchedEntry);
         }
@@ -875,7 +874,7 @@ public class CachingHttpClient implement
         Date responseDate = getCurrentDate();
 
         if (revalidationResponseIsTooOld(backendResponse, cacheEntry)) {
-            EntityUtils.consume(backendResponse.getEntity());
+            IOUtils.consume(backendResponse.getEntity());
             final HttpRequest unconditional = conditionalRequestBuilder
                 .buildUnconditionalRequest(request, cacheEntry);
             requestDate = getCurrentDate();
@@ -907,7 +906,7 @@ public class CachingHttpClient implement
             cachedResponse.addHeader(HeaderConstants.WARNING, "110 localhost \"Response is stale\"");
             final HttpEntity errorBody = backendResponse.getEntity();
             if (errorBody != null) {
-                EntityUtils.consume(errorBody);
+                IOUtils.consume(errorBody);
             }
             return cachedResponse;
         }

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java Mon Feb 17 13:16:26 2014
@@ -64,7 +64,6 @@ import org.apache.http.message.BasicHttp
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
 import org.apache.http.util.VersionInfo;
 
 /**
@@ -634,7 +633,7 @@ public class CachingExec implements Clie
             final Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG);
             if (resultEtagHeader == null) {
                 log.warn("304 response did not contain ETag");
-                EntityUtils.consume(backendResponse.getEntity());
+                IOUtils.consume(backendResponse.getEntity());
                 backendResponse.close();
                 return callBackend(route, request, context, execAware);
             }
@@ -643,7 +642,7 @@ public class CachingExec implements Clie
             final Variant matchingVariant = variants.get(resultEtag);
             if (matchingVariant == null) {
                 log.debug("304 response did not contain ETag matching one sent in If-None-Match");
-                EntityUtils.consume(backendResponse.getEntity());
+                IOUtils.consume(backendResponse.getEntity());
                 backendResponse.close();
                 return callBackend(route, request, context, execAware);
             }
@@ -651,7 +650,7 @@ public class CachingExec implements Clie
             final HttpCacheEntry matchedEntry = matchingVariant.getEntry();
 
             if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) {
-                EntityUtils.consume(backendResponse.getEntity());
+                IOUtils.consume(backendResponse.getEntity());
                 backendResponse.close();
                 return retryRequestUnconditionally(route, request, context, execAware, matchedEntry);
             }

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java Mon Feb 17 13:16:26 2014
@@ -34,11 +34,24 @@ import java.io.OutputStream;
 import java.io.RandomAccessFile;
 import java.nio.channels.FileChannel;
 
+import org.apache.http.HttpEntity;
 import org.apache.http.annotation.Immutable;
 
 @Immutable
 class IOUtils {
 
+    static void consume(final HttpEntity entity) throws IOException {
+        if (entity == null) {
+            return;
+        }
+        if (entity.isStreaming()) {
+            final InputStream instream = entity.getContent();
+            if (instream != null) {
+                instream.close();
+            }
+        }
+    }
+
     static void copy(final InputStream in, final OutputStream out) throws IOException {
         final byte[] buf = new byte[2048];
         int len;

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java Mon Feb 17 13:16:26 2014
@@ -46,7 +46,6 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.utils.DateUtils;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
 
 /**
  * @since 4.1
@@ -94,7 +93,7 @@ class ResponseProtocolCompliance {
     private void consumeBody(final HttpResponse response) throws IOException {
         final HttpEntity body = response.getEntity();
         if (body != null) {
-            EntityUtils.consume(body);
+            IOUtils.consume(body);
         }
     }
 

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java Mon Feb 17 13:16:26 2014
@@ -35,7 +35,6 @@ import java.lang.reflect.Method;
 
 import org.apache.http.HttpResponse;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.EntityUtils;
 
 /**
  * A proxy class that can enhance an arbitrary {@link HttpResponse} with
@@ -64,7 +63,7 @@ class ResponseProxyHandler implements In
     }
 
     public void close() throws IOException {
-        EntityUtils.consume(original.getEntity());
+        IOUtils.consume(original.getEntity());
     }
 
     public Object invoke(

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java Mon Feb 17 13:16:26 2014
@@ -62,7 +62,6 @@ import org.apache.http.entity.BasicHttpE
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -510,7 +509,7 @@ public class TestBasicHttpCache {
         originResponse.setHeader("ETag", "\"etag\"");
 
         final HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
-        EntityUtils.consume(result.getEntity());
+        IOUtils.consume(result.getEntity());
         assertTrue(inputStream.wasClosed());
     }
 

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java Mon Feb 17 13:16:26 2014
@@ -341,7 +341,7 @@ public class TestCachingExec extends Tes
                 }
                 return 'y';
             }
-        }));
+        }, -1));
 
         final CloseableHttpResponse resp = mockBackend.execute(
                 EasyMock.isA(HttpRoute.class),

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java Mon Feb 17 13:16:26 2014
@@ -38,11 +38,10 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpRequestWrapper;
 import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.client.utils.DateUtils;
+import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.impl.execchain.ClientExecChain;
 import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.util.EntityUtils;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Assert;
@@ -116,7 +115,7 @@ public class TestHttpCacheJiraNumber1147
 
         final HttpResponse response1 = t.execute(route, get, context, null);
         Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
-        EntityUtils.consume(response1.getEntity());
+        IOUtils.consume(response1.getEntity());
 
         EasyMock.verify(backend);
 
@@ -132,7 +131,7 @@ public class TestHttpCacheJiraNumber1147
 
         final HttpResponse response2 = t.execute(route, get, context, null);
         Assert.assertEquals(200, response2.getStatusLine().getStatusCode());
-        EntityUtils.consume(response2.getEntity());
+        IOUtils.consume(response2.getEntity());
 
         EasyMock.verify(backend);
     }

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java?rev=1568975&r1=1568974&r2=1568975&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java Mon Feb 17 13:16:26 2014
@@ -26,12 +26,12 @@
  */
 package org.apache.http.impl.client.cache;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.MethodNotSupportedException;
-import org.apache.http.Header;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.cache.CacheResponseStatus;
@@ -41,10 +41,10 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -53,10 +53,8 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Locale;
 
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import org.apache.http.localserver.LocalTestServer;
 
 /**
  * Test that after background validation that a subsequent request for non cached
@@ -205,7 +203,7 @@ public class TestStaleWhileRevalidationR
             if(response!=null) {
                 final HttpEntity entity = response.getEntity();
                 try {
-                    EntityUtils.consume(entity);
+                    IOUtils.consume(entity);
                 } catch (final IOException e) {
                     e.printStackTrace();
                 }



Mime
View raw message