HTTP Receiving file

I have couple problems.
Is there some good way to strip down HTTP header from response since when receiving the first time there is some data from the file so trashing that packet completely isn't option. I think searching for \r\n\r\n can find me end of the header tho but wondering if there is more standard/better way.

Also biggest problem is that I can't receive file completely, I get random file sizes. From 5mb file for example I got only 800kb.

1
2
3
4
5
6
7
8
9
10
// First recv()
HTTP/1.1 200 OK
Server: apache
Content-Type: application/zip
Content-Length: 5000000
Connection: keep-alive
Access-Control-Allow-Origin: *
Accept-Ranges: bytes

FILE I WANT TO DOWNLOAD, SOME HEADER DATA


1
2
3
4
5
6
7
8
9
// Loop to receive a file
FILE *download;
int bytes;
char buffer[3000];
download=fopen("destination.zip","w");
do{
bytes=recv(socket,buffer,3000,0);
fputs(buffer,download)}
while(0<bytes);

Topic archived. No new replies allowed.