Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Premature end of Content-Length delimited message body #61

Open
raulmontemayor opened this issue Aug 5, 2021 · 3 comments
Open

Premature end of Content-Length delimited message body #61

raulmontemayor opened this issue Aug 5, 2021 · 3 comments

Comments

@raulmontemayor
Copy link

No problem using org.aarboard.nextcloud.api.NextcloudConnector.downloadFile(String, String) to directly save a file.
But if I use org.aarboard.nextcloud.api.NextcloudConnector.downloadFile(String) :

try (InputStream in = nextcloud.downloadFile(path + "/" + fileName)) {
	int bytesRead;
	byte[] buffer = new byte[4096];
	try (OutputStream outStream = new FileOutputStream("/Users/development/" + fileName)) {
		while ((bytesRead = in.read(buffer)) != -1) {
			outStream.write(buffer, 0, bytesRead);
		}
		outStream.flush();
		outStream.close();
	}
}

it fails with:

org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 2,208,611; received: 6,745)
	at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:140) ~[httpcore-4.4.14.jar:4.4.14]
	at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:118) ~[httpclient-4.5.13.jar:4.5.13]
	at com.github.sardine.impl.io.ByteCountInputStream.read(ByteCountInputStream.java:44) ~[sardine-5.10.jar:5.10]
	at com.github.sardine.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:50) ~[sardine-5.10.jar:5.10]
	at org.apache.commons.io.input.ProxyInputStream.read(ProxyInputStream.java:62) ~[commons-io-2.8.0.jar:2.8.0]

Am I doing something wrong?

Library version: 11.5.0
Nextcloud version: 17.0.0

@scaamanho
Copy link

scaamanho commented Jan 7, 2022

Same problem with:
Library version 12.0.0
Nextcloud: 22.2.2

downloadFile(String, String)

seems works in all cases, but

downloadFile(String)

only works if file downloaded is small, if file have 5k or more i get the same error show avove

@SimonIT
Copy link
Contributor

SimonIT commented Jan 11, 2023

The error occurs for me after updating from 11.2.0 to 11.3.0 until the newest version

@valentindruon
Copy link

valentindruon commented Feb 2, 2023

Same here
Library : 12.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants