New to python and websockets but I am trying to do the following:
import httplib
conn = httplib.HTTPConnection('localhost:8888')
conn.putheader('Connection', 'Upgrade')
conn.putheader('Upgrade', 'websocket')
conn.endheaders()
conn.send('Hello to websocket!')
Crashes when it reaches putheader
Server code is written in Node.js
var http = require('http');
http.createServer(function (request, response) {
console.log(request);
}).on('upgrade', function(request, socket, head) {
console.log('Upgrade request! Woohoo!');
socket.connect(8080, 'localhost', function(data) {
console.log('data');
});
socket.write('Socket is open!');
}).listen(8888);
Not really worried about the server code being correct (I'll fix it if need be once I get a request sent from my Python client), but I am wondering how to upgrade a connection to websocket using httplib (if it is possible).