http response receive using socket

Hi, I make a simple c++ http post request using socket and it is working fine. But I have no idea how to get only the message of the response. Here is my receive code:

1
2
3
char buffer[1028];
recv(socket, buffer, sizeof(buffer), 0);
printf("%s", buffer);


Then here is the response that the http send back.

1
2
3
4
5
6
7
8
HTTP/1.1 200 OK
Data: Mon, 19 May 2014 12:46:36 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27
X-Powered-By: PHP/5.4.27
Coneten-Length: 28
Content-Type: text/html

All done! Do some stuff now.


Okay. So what I want to try is get 3 things in this response and put them to string vector but I have no idea how to do this. What I need is to parse the response and the 200 OK, 28 and All done! Do some stuff now. then put them to string vector.

expected result

1
2
3
response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now


Thanks
1
2
3
4
5
6
7
8
HTTP/1.1 200 OK
Data: Mon, 19 May 2014 12:46:36 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27
X-Powered-By: PHP/5.4.27
Coneten-Length: 28
Content-Type: text/html

All done! Do some stuff now.

So what I want to try is get 3 things in this response and put them to string vector but I have no idea how to do this.

expected result
1
2
3
response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now


It's all there. It's not clear what you have a problem with.
i need to parse the response message so instead of outputting the header with the body message, i can compare what the response is.
Topic archived. No new replies allowed.