function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
D_M_CD_M_C 

Download remote text file - Premature EOF

I have to call a service to generate a text file.  When the text file is ready, I have to download the text file.  The text file is pushed as an HTTP download when the URL is used in a browser (I assume due to the content type of application/octet-stream).  The problem is that the Apex code breaks on the HTTP.send(), throwing "System.CalloutException: Premature EOF". 

 

Please note that if I call the URL (in Apex) before the file is ready, then I recieve the error message from the server properly (meaning the Apex does not crash and I can see the error message in the debug logs).  This suggests to me that I am making the call correctly.

 

Is there a way to download this file for in-memory processing in Apex?

D_M_CD_M_C

It seems that the problem was based on the server using Chunking to return the file.  When the file is not chunked, it works.