The Protocol used, I believe HTTP?
Open a TCP connection with the server, generate the HTTP request, receive HTTP response, which will contain including and your file. But the file will still be HTTP headers. Parsite HTTP response to get the output of your file.
In principle it is possible to read the stream byte and feed it to each byte the parser the parser will separate the service information from the HTTP response body, the body will contain your file.
Such a streaming HTTP parser, for example, in C library http-parser from structure node.js. Nginx also uses a similar parser, but it is not highlighted as a separate library.
There are nuances, for example, the server could compress the file, information about the method of compression in the headers, you will have to unzip the file.
Can also be HTTPS instead of HTTP, basically the same thing only the entire stream is still encrypted, i.e. you will need to open a connection, not directly, but via openssl (usually). At the exit of HTTPS will be the same HTTP.
Still, the server does not immediately give the file and send first response 202, or redirect to another resource (don't remember the code of the answer), or even error.
Use ready-made implementation, for example libcurl.