Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for http://forum.yacy-websuche.de/viewtopic.php?f=5&t=1396
danielr4d937f6b2166
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.javaindex 3a1323a30..357e12503 100644--- a/source/de/anomic/http/httpdProxyHandler.java+++ b/source/de/anomic/http/httpdProxyHandler.java@@ -986,9 +986,17 @@ public final class httpdProxyHandler {// input so we have to end it to do the requestfinal long requestLength = requestHeader.contentLength();if(requestLength > -1) {- final ByteArrayOutputStream buffer = new ByteArrayOutputStream();- serverFileUtils.copy(body, buffer, requestLength);- body = new ByteArrayInputStream(buffer.toByteArray());+ final byte[] bodyData;+ if(requestLength == 0) {+ // no body+ bodyData = new byte[0];+ } else {+ // read content-length bytes into memory+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();+ serverFileUtils.copy(body, buffer, requestLength);+ bodyData = buffer.toByteArray();+ }+ body = new ByteArrayInputStream(bodyData);}JakartaCommonsHttpResponse res = null;try {diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.javaindex 93490eee0..52fda469b 100644--- a/source/de/anomic/server/serverFileUtils.java+++ b/source/de/anomic/server/serverFileUtils.java@@ -69,7 +69,7 @@ public final class serverFileUtils {** @param source InputStream* @param dest OutputStream- * @param count the total amount of bytes to copy (-1 for all)+ * @param count the total amount of bytes to copy (-1 for all, else must be greater than zero)* @return Total number of bytes copied.* @throws IOException*@@ -79,6 +79,12 @@ public final class serverFileUtils {* @see #copy(File source, File dest)*/public static long copy(final InputStream source, final OutputStream dest, final long count) throws IOException {+ assert count == -1 || count > 0 : "precondition violated: count == -1 || count > 0 (nothing to copy)";+ if(count == 0) {+ // no bytes to copy+ return 0;+ }+final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];int chunkSize = (int) ((count > 0) ? Math.min(count, DEFAULT_BUFFER_SIZE) : DEFAULT_BUFFER_SIZE);