NODE JS Code:
var data = ''; sslserv.on('request', function(request, response) { if ((request.method=='POST' || request.method=='GET') && request.url.indexOf('socket')==-1){ var data_arr = []; request.on('data', function(chunk) { data = chunk.toString(); console.log(data); }); request.on('end', function() { if (!data){ response.write('It\'s Work!'); response.end(); } }); } }); Here is the PHP submission code:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://127.0.0.1:8888"); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); result = curl_exec($ch); curl_close($ch); When a request with a length of more than 900-1000 characters arrives at the node through PHP_CURL, not the information that was sent to the console! The line may appear an extra space or a line break ...
Everything would be okay, but I parse this line through JSON.parse and eventually the error crashes! )) I sinned on the function but after I paid attention to the fact that the request data is distorted!
Why? How to fix ?