Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: HTTP Stream Response  (Read 2100 times)

0 Members and 1 Guest are viewing this topic.

SMURF4o0o

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
HTTP Stream Response
« on: July 07, 2015, 11:55:16 am »
Hey guys I am trying to download an installer via HTTP.
My issue is since the installer can be quite large (currently 400MB with the possibility of growing), when the response is recieved the memory usage jumps as high as 900MB and my program crashes.
I am trying to flush the binary response to a file, so I can make a sillent install later on.
Is it possible to make the response streaming via the HTTP protocol (I am trying to avoid using ftp as that would mean dropping SFTP for FTP protocol, having a dedicated account for the download and so on).
Any suggestions on how to resolve my issue would be greatly appreciated.
Thanks
PS: Awesome Library

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: HTTP Stream Response
« Reply #1 on: July 07, 2015, 12:25:08 pm »
It's not possible with the sf::Http class and similar, however you can implement it with a bit more work with sockets.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: HTTP Stream Response
« Reply #2 on: July 07, 2015, 11:24:58 pm »
Haven't tried it, but you should be able to download the file in multiple parts by setting the proper "Content-range" header (your server has to support that though). E.g. you could download the file in 1-10 mb snippets, each handled by its own thread (just make sure not to overload the computer and network :P).

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: HTTP Stream Response
« Reply #3 on: July 15, 2015, 07:35:10 pm »
Another low-tech solution would be to just split the file into chunks on the server side, so that you'd be downloading file.1, file.2, file.N individually and then just combine them into one on the client side once all chunks have been downloaded.

 

anything