115,119c115,119 < from cStringIO import StringIO < from Queue import Queue < regex_head = re.compile('^((http|https|HTTP|HTTPS)\://[^/]+)?(?P\w+)\s+(?P\S+)\s+(?P\S+)') < regex_header = re.compile('\s*(?P.*?)\s*\:\s*(?P.*?)\s*$') < regex_chunk = re.compile('^(?P\w+)') --- > from io import StringIO > from queue import Queue > regex_head = re.compile(b'^((http|https|HTTP|HTTPS)\://[^/]+)?(?P\w+)\s+(?P\S+)\s+(?P\S+)') > regex_header = re.compile(b'\s*(?P.*?)\s*\:\s*(?P.*?)\s*$') > regex_chunk = re.compile(b'^(?P\w+)') 216c216 < break --- > break 231c231 < uri = match.group('uri') --- > uri = str(match.group('uri')) 252c252 < if line == '\r\n': --- > if line == b'\r\n': 257,260c257,258 < key = match.group('key').upper().replace('-','_') < if isinstance(key,unicode): < key = key.encode('ISO-8859-1') < value = match.group('value') --- > key = str(match.group('key')).upper().replace('-','_') > value = str(match.group('value')) 290c288 < headers.append(('Content-Length',len(data_items[0]))) --- > headers.append(('Content-Length',len(bytes(data_items[0],'utf8')))) 296c294 < client_socket.sendall(data) --- > client_socket.sendall(bytes(data,'utf8')) 300c298 < client_socket.sendall('%x\r\n%s\r\n' % (len(data),data)) --- > client_socket.sendall(bytes('%x\r\n%s\r\n' % (len(data),data),'utf8')) 302,303c300,301 < client_socket.sendall(data) < except socket.error, e: --- > client_socket.sendall(bytes(data,'utf8')) > except socket.error as e: 307c305 < client_socket.sendall('0\r\n') --- > client_socket.sendall(b'0\r\n') 315c313 < "HTTP/1.0 %s\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n\r\n" % status) --- > b"HTTP/1.0 %s\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n\r\n" % status) 386c384 < print 'Experimental "Sneaky" WSGI web server. Starting...' --- > print ('Experimental "Sneaky" WSGI web server. Starting...') 457c455 < print 'serving from: '+address --- > print ('serving from: '+address)