I use socket client to send http request, all works fine, but some time, some host return strange/wrong data. for example:
HTTP/1.1 200 OK
Date: Tue, 12 May 2020 23:19:07 GMT
Server: Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.6
X-Powered-By: PHP/7.2.6
Transfer-Encoding: chunked
Content-Type: application/json
2322
{"content_type":"application/json","response":{"datetime":"2020-05-13 02:19:07","result":0,"signature":""}}
0
correct data is:
HTTP/1.1 200 OK
Date: Tue, 12 May 2020 23:19:07 GMT
Server: Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.6
X-Powered-By: PHP/7.2.6
Transfer-Encoding: chunked
Content-Type: application/json
{"content_type":"application/json","response":{"datetime":"2020-05-13 02:19:07","result":0,"signature":""}}
i get it if use POSTMAN. to recive data from host I use code:
int len = 512;
char buf_new[1000000];
buf_new[0] = '\0';
do {
len = recv(socket, buf_new, 512, 0);
buf_new[len] = 0;
Result += buf_new;
buf_new[0] = '\0';
} while (len > 0);
If anyone know what is problem - please help, thanks!