mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5073 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
5192081283
commit
4d937f6b21
|
@ -986,9 +986,17 @@ public final class httpdProxyHandler {
|
|||
// input so we have to end it to do the request
|
||||
final long requestLength = requestHeader.contentLength();
|
||||
if(requestLength > -1) {
|
||||
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);
|
||||
body = new ByteArrayInputStream(buffer.toByteArray());
|
||||
bodyData = buffer.toByteArray();
|
||||
}
|
||||
body = new ByteArrayInputStream(bodyData);
|
||||
}
|
||||
JakartaCommonsHttpResponse res = null;
|
||||
try {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user