I am trying to get HTTP response with the help of apache httpclient. I get headers successfully but it throws exception when I try to get contents. Exception is:
Caused by: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 42 320; received: 7 787)
[INFO] [talledLocalContainer] at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178) ~[httpcore-4.4.15.jar:4.4.15]
[INFO] [talledLocalContainer] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135) ~[httpclient-4.5.13.jar:4.5.13]
[INFO] [talledLocalContainer] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148) ~[httpclient-4.5.13.jar:4.5.13]
[INFO] [talledLocalContainer] at com.blueway.common.utils.BWFileUtils.writeToFile(BWFileUtils.java:207) ~[engine-module-common-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.platform.app.engine.technicalconnector.impl.service.azureblobstorage.AzureBlobStorageService.getBlob(AzureBlobStorageService.java:49) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.platform.app.engine.technicalconnector.impl.service.azureblobstorage.invoker.AzureBlobStorageGetBlobInvoker.invoke(AzureBlobStorageGetBlobInvoker.java:22) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.platform.app.engine.technicalconnector.impl.service.azureblobstorage.AzureBlobStorageInvokeWrapper.doInvoke(AzureBlobStorageInvokeWrapper.java:34) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.support.ConnectorAzureBlobStorage.invoke(ConnectorAzureBlobStorage.java:46) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.service.instruction.ConnectorHandlingInstruction.invokeConnector(ConnectorHandlingInstruction.java:68) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.service.instruction.ConnectorHandlingInstruction.executeInstructionWithSupport(ConnectorHandlingInstruction.java:50) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.service.instruction.ConnectorHandlingInstruction.executeInstructionWithSupport(ConnectorHandlingInstruction.java:19) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.service.instruction.SupportHandlingInstruction.executeInstruction(SupportHandlingInstruction.java:99) ~[web-0.0.1-SNAPSHOT.jar:?]
[INFO] [talledLocalContainer] at com.blueway.engine52.service.instruction.Instruction.tryExecuteInstruction(Instruction.java:363) ~[web-0.0.1-SNAPSHOT.jar:?]
and the code is
public CloseableHttpResponse get(final String containerName, final String blobName) throws AzBException{
final Logger logger = LoggerFactory.getLogger(getClass());
final String url = HTTPS + accountName + END_POINT + containerName + "/" + blobName;
try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
final HttpGet httpGet = new HttpGet(url);
logger.debug("Sending HTTP GET request to URL: {}", url);
final CloseableHttpResponse response = httpClient.execute(httpGet);
logger.debug("Received HTTP response with status code: {}", response.getStatusLine().getStatusCode());
return response;
} catch (IOException e) {
throw new AzBException("An.get HttpGet error: " + e.getCause().getMessage(), e);
}
}
any help will be appreciated. thanks