summaryrefslogtreecommitdiff
path: root/omegle.py
diff options
context:
space:
mode:
Diffstat (limited to 'omegle.py')
-rw-r--r--omegle.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/omegle.py b/omegle.py
index 395bf4b..62a3892 100644
--- a/omegle.py
+++ b/omegle.py
@@ -54,6 +54,7 @@ class RESTClient(object):
try:
headers = RESTClient.headers.copy()
headers['Host'] = self.host
+ headers['Content-Length'] = str(len(params))
self.conn.request(method,path,params,headers)
resp = self.conn.getresponse()
finally:
@@ -94,14 +95,14 @@ class OmegleChat(RESTClient):
def disconnect(self):
"""Close a chat session."""
self.logger.debug("disconnect()")
- self.is_connected = False
+ self.is_confirmed = False
self.timer.stop()
if self.is_confirmed:
r = RESTClient.request(self,"POST", "/disconnect", urllib.urlencode({'id': self.id}))
body = r.read()
self.logger.debug("/disconnect sent. Read: %s" % body)
if body == "win":
- self.is_confirmed = False
+ self.is_connected = False
self.id = None
self.conn.close()
else:
@@ -110,9 +111,13 @@ class OmegleChat(RESTClient):
def _events(self):
"""does use its own "HTTPConnection" because its called async from a thread"""
conn = httplib.HTTPConnection(self.host)
+ params = urllib.urlencode({'id' : self.id})
+ headers = OmegleChat.headers.copy()
+ headers['Host'] = "omegle.com"
+ headers['Content-Length'] = str(len(params))
conn.request("POST",
"/events",
- urllib.urlencode({'id' : self.id}),
+ params,
OmegleChat.headers)
r=conn.getresponse()
body=r.read()