Download HTTP thru sockets (C)

后端 未结 3 1570
悲哀的现实
悲哀的现实 2021-02-06 08:06

Recently I started taking this guide to get myself started on downloading files from the internet. I read it and came up with the following code to download the HTTP body of a w

3条回答
  •  迷失自我
    2021-02-06 08:54

    The problem is, you have to implement the HTTP protocol. Downloading a file is not just a matter of connecting to the server, you have to send HTTP requests (along with proper HTTP header) before you get a response. After this, you would still need to parse the returned data to strip out more HTTP headers.

    If you're just trying to download files using C, I suggest the cURL library, which does the HTTP work for you.

提交回复
热议问题