I\'m trying to send a \"post\" reguest to my php file and get the info back, it works fine, but
it also print something before printing my response from the php fil
The responses header bit is separated from the content by a blank line.
Need to take into account different line endings. Basically ignore \r
s.
So 1st read lines until you get a blank one then start printing them!
EDIT
You have a response as follows
HTTP/1.1 200 OK
Date: Fri, 20 Apr 2012 10:19:12 GMT
...
Content-Type: text/html
Hello World
Notice that there is a blank line between the HTTP headers and the response (HTML in this case).
First part of the response you received is made up of HTTP version, Server Response Status Code and various HTTP response headers.
HTTP/1.1 200 OK Date: Fri, 20 Apr 2012 10:19:12 GMT Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 X-Powered-By: PHP/5.3.6 Content-Length: 12 Connection: close Content-Type: text/html
After headers follows HTTP response body (which you need to extract):
hello world
HTTP headers and body are separated with the following sequence of characters: \r\n\r\n
. So all you need to do is to search for it and extract everything that is behind it.
You can do this yourself (sockets, parsing...) but my advice is to use some of HTTP libraries: WinInet
, WinHttp
(both are Microsoft's) or libCurl
(open source).