Delete HTTP Header Information

Is there a way in C to exclude the HTTP header information that comes with the data when used recv()on a socket? I am trying to read some binary data, and all I want is the actual binary information, not the HTTP header information. The resulting current data is as follows:

HTTP/1.1 200 OK
Content-Length: 3314
Content-Type: image/jpeg
Last-Modified: Tue, 20 Mar 2012 14:51:34 GMT
Accept-Ranges: bytes
ETag: "45da99f1a86cd1:6b9"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Mon, 20 Aug 2012 14:10:08 GMT
Connection: close 

╪ α

I would just read the binary part of the file. (Obviously, not all binary, only so much has been shown, since I printed the output from my recv loop as a string, and the first NULL char after this small binary string).

I just need to get rid of the header part, is there an easy way to do this?

+5
source share
2 answers

, Content-Length, , , , . , , , , "\r\n\r\n", .

+6

HTTP, curl

:

'\r\n\r\n' (two \r\n), HTTP /.

, Content-Length , http.

- :

/* http_resp has data read from recv */
httpbody = strstr(http_resp, "\r\n\r\n");
if(httpbody) 
    httpbody += 4; /* move ahead 4 chars
/* now httpbody  has just data, stripped down http headers */

: , strstr , strnstr ( , ) .

+6

All Articles