You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/09 20:01:41 UTC
[15/50] httpcomponents-core git commit: Refactor magic number.
Refactor magic number.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1778357 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/5f800413
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/5f800413
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/5f800413
Branch: refs/heads/4.4.x
Commit: 5f800413a371dcb07e794e8d03cafad8b2d65110
Parents: a15ca59
Author: Gary D. Gregory <gg...@apache.org>
Authored: Wed Jan 11 23:44:17 2017 +0000
Committer: Gary D. Gregory <gg...@apache.org>
Committed: Wed Jan 11 23:44:17 2017 +0000
----------------------------------------------------------------------
httpcore/src/main/java/org/apache/http/util/EntityUtils.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5f800413/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
index 83297f0..e401f4e 100644
--- a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
@@ -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) {