I have a c++ program that use socket to make HTTP POST Request. My question is how to parse the response that the server sent and put it in string vector.
Here is my code for receive:
char buffer[1028];
recv(socket, buffer, sizeof(buffer), 0);
printf("%s", buffer);
Then here is the response:
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.
And what I want to get from this response are 3 message. The 200 OK, the 28 (content-length) and the actual response message "All done! Do some stuff now."
And here is my expected result:
response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now