0
Отвечен

How to send a http post (including cookie) in JavaScript. What's the syntax?

Abhijeet Ramgir 9 лет назад в iRidium Script обновлен Sergey (expert) 9 лет назад 2
Hello,
I just want to send an HTTP POST (including cookie) to a device. How can I do that using JavaScript?
Thanks,
Abhijeet
Отвечен
Hi, Abhijeet

It is a syntax example to send Cookie by TCP Driver.


var post = '{"Data1": "value1","Data2":"'value2"}';

var packet = 'POST ' + '/news.html' + ' HTTP/1.0\n' +
'Host: ' + 'www.site.ru'+ ':' + '80' + '\n'+
'Connection: keep-alive\n'+
'Content-Type: application/json\n'+
'User-Agent: Mozilla/3.0 (compatible; Indy Library)\n'+
'Accept-Encoding: identity\n'+
'Content-Length: '+ post.length + '\n\n' + post + '\n' +
'Cookie: income=1';

var Driver = IR.GetDevice("AV & Custom System TCP");

Driver.Send[packet];

Сервис поддержки клиентов работает на платформе UserEcho