failed hopes

This commit is contained in:
Christine Dodrill 2015-11-15 09:13:12 -08:00
parent 94738dd5db
commit c0d4330383
3 changed files with 11 additions and 6 deletions

View File

@ -66,7 +66,9 @@ class crlf_tcp(object):
while True:
try:
data = self.recv_from_socket(4096)
self.ibuffer += data
print(type(self.ibuffer))
print(type(data))
self.ibuffer += (data.decode('utf-8'))
if data:
last_timestamp = time.time()
else:
@ -88,9 +90,11 @@ class crlf_tcp(object):
while True:
line = self.oqueue.get().splitlines()[0][:500]
print(">>> %r" % line)
self.obuffer += line.encode('utf-8', 'replace') + '\r\n'
while self.obuffer:
sent = self.socket.send(self.obuffer)
self.obuffer += (line + '\r\n')
while len(self.obuffer) > 0:
sent = self.socket.send(self.obuffer.encode('utf-8', 'replace'))
self.obuffer = self.obuffer[sent:]

View File

@ -1,6 +1,7 @@
import fuckit
import _thread
import traceback
import queue
_thread.stack_size(1024 * 512) # reduce vm size
@ -99,7 +100,7 @@ class Handler(object):
def __init__(self, func):
self.func = func
self.input_queue = Queue.Queue()
self.input_queue = queue.Queue()
_thread.start_new_thread(self.start, ())
def start(self):

View File

@ -73,7 +73,7 @@ def normalize(url):
# Always use uppercase A-through-F characters when percent-encoding.
# All portions of the URI must be utf-8 encoded NFC from Unicode strings
def clean(string):
string = str(unquote(string), 'utf-8', 'replace')
string = b""+(unquote(string)).decode('utf-8', 'replace')
return unicodedata.normalize('NFC', string).encode('utf-8')
path = quote(clean(path), "~:/?#[]@!$&'()*+,;=")
fragment = quote(clean(fragment), "~")