hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1778357 - /httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
Date Wed, 11 Jan 2017 23:44:17 GMT
Author: ggregory
Date: Wed Jan 11 23:44:17 2017
New Revision: 1778357

URL: http://svn.apache.org/viewvc?rev=1778357&view=rev
Log:
Refactor magic number.

Modified:
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java?rev=1778357&r1=1778356&r2=1778357&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
Wed Jan 11 23:44:17 2017
@@ -50,6 +50,8 @@ import org.apache.http.protocol.HTTP;
  */
 public final class EntityUtils {
 
+    private static final int DEFAULT_BUFFER_SIZE = 4096;
+
     private EntityUtils() {
     }
 
@@ -128,10 +130,10 @@ public final class EntityUtils {
                     "HTTP entity too large to be buffered in memory");
             int i = (int)entity.getContentLength();
             if (i < 0) {
-                i = 4096;
+                i = DEFAULT_BUFFER_SIZE;
             }
             final ByteArrayBuffer buffer = new ByteArrayBuffer(i);
-            final byte[] tmp = new byte[4096];
+            final byte[] tmp = new byte[DEFAULT_BUFFER_SIZE];
             int l;
             while((l = instream.read(tmp)) != -1) {
                 buffer.append(tmp, 0, l);
@@ -205,7 +207,7 @@ public final class EntityUtils {
                     "HTTP entity too large to be buffered in memory");
             int i = (int)entity.getContentLength();
             if (i < 0) {
-                i = 4096;
+                i = DEFAULT_BUFFER_SIZE;
             }
             Charset charset = null;
             if (contentType != null) {



Mime
View raw message