Fix #19: python2.4 support.
- Replace URL parsing using "".partition() with urlparse module.
This commit is contained in:
parent
801482be6a
commit
c95c24e743
|
@ -15,6 +15,7 @@ import sys, socket, ssl, struct, traceback
|
||||||
import os, resource, errno, signal # daemonizing
|
import os, resource, errno, signal # daemonizing
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode, b64decode
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
from urlparse import urlsplit, parse_qsl
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
'listen_host' : '',
|
'listen_host' : '',
|
||||||
|
@ -73,7 +74,7 @@ def parse_handshake(handshake):
|
||||||
ret['path'] = req_lines[0].split(" ")[1]
|
ret['path'] = req_lines[0].split(" ")[1]
|
||||||
for line in req_lines[1:]:
|
for line in req_lines[1:]:
|
||||||
if line == "": break
|
if line == "": break
|
||||||
var, delim, val = line.partition(": ")
|
var, val = line.split(": ")
|
||||||
ret[var] = val
|
ret[var] = val
|
||||||
|
|
||||||
if req_lines[-2] == "":
|
if req_lines[-2] == "":
|
||||||
|
@ -132,9 +133,8 @@ def do_handshake(sock):
|
||||||
h = parse_handshake(handshake)
|
h = parse_handshake(handshake)
|
||||||
|
|
||||||
# Parse client settings from the GET path
|
# Parse client settings from the GET path
|
||||||
cvars = h['path'].partition('?')[2].partition('#')[0].split('&')
|
cvars = parse_qsl(urlsplit(h['path'])[3], True)
|
||||||
for cvar in [c for c in cvars if c]:
|
for name, val in cvars:
|
||||||
name, _, val = cvar.partition('=')
|
|
||||||
if name not in ['b64encode']: continue
|
if name not in ['b64encode']: continue
|
||||||
value = val and val or True
|
value = val and val or True
|
||||||
client_settings[name] = value
|
client_settings[name] = value
|
||||||
|
|
Loading…
Reference in New Issue