socket.makefile issues in python 3 while creating a http proxy -
from socket import * import sys # create server socket, bind port , start listening tcpsersock = socket(af_inet, sock_stream) serverport = 12000 tcpsersock.bind(('', serverport)) tcpsersock.listen(1) print ("server ready") while 1==1: # start receiving data client. e.g. request = "get http://localhost:portnum/www.google.com" tcpclisock, addr = tcpsersock.accept() print ('received connection from:', addr) request = str(tcpclisock.recv(1024).decode()) print ("requested " + request) # extract file name given request filename = request.split()[1] print ("file name " + filename) fileexist = "false" filetouse = "/" + filename print ("file use: " + filetouse) try: # check wether file exist in cache. open fail , go "except" in case file doesn't exist. similar try/catch in java f = open(filetouse[1:], "r") outputdata = f...