i should be send data on /node_api (python+djnago), i use node.js with socket.io:
socket.on('send_message', function (message) {
values = querystring.stringify({
comment: message, // not null
sessionid: socket.handshake.cookie['sessionid'],
});
var options = {
host: 'localhost',
port: 8000,
path: '/node_api',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': values.length
}
};
var req = http.get(options, function(res){
res.setEncoding('utf8');
res.on('data', function(message){
if(message != 'work'){
console.log('Message: ' + message);
}
});
});
req.write(values);
req.end();
but data does not sended, in my views.py:
request.POST.get('comment','null') # null
request is ok, but why POST is empty?
if i console.log(req) i look
method: 'GET',
path: '/node_api',
_events: { response: [Function] },
_headers:
{ 'content-type': 'application/x-www-form-urlencoded',
'content-length': 52,
host: 'localhost:8000' },
_headerNames:
{ 'content-type': 'Content-Type',
'content-length': 'Content-Length',
host: 'Host' },
_header: 'GET /node_api HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 52\r\nHost: localhost:8000\r\nConnection: keep-alive\r\n\r\n',
i dont know, but method is GET...and GET null too
please help me!!!