Isabel Cariod Isabel Cariod - 24 days ago 4
C Question

How to get only Message Body from a GET HTTP request?

I make a HTTP GET request

char write = "GET /image.png HTTP/1.1\r\n";

enter image description here

And response header

HTTP/1.1 200 OK
Content-Type: image/png
Date: Mon, 26 Sep 2016 03:40:54 GMT
Connection: keep-alive
Content-Length: 14021


Is there a way to get only message body and avoid response headers?


According to RFC 7230 the response is in the format below:

HTTP-message   = start-line
                  *( header-field CRLF )
                  [ message-body ]

So search in your result for the first two CRLF's in a row. There is where the body starts..