如何从GET HTTP请求中仅获取Message Body?

时间:2016-10-03 13:01:36

标签: c http get http-headers

我发出HTTP GET请求

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

enter image description here

响应标题

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

�PNG�;oq

有没有办法只获取邮件正文并避免响应标题?

1 个答案:

答案 0 :(得分:1)

根据RFC 7230,回复的格式如下:

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

因此,在结果中搜索前两个CRLF。身体开始的地方..