Adding POST to SimpleHTTPServer as a proxy

UPDATED I made a simple proxy server based on SimpleHTTPServer , but I have a problem with the POST method, when someone asks for the POST method, it shows an error, so I made the do_POST() function, but when I request using POST (works fine with most sites except vbulletin script ! ), I just get the message: connection was reset

so now the problem is that I'm trying to log in to the vbulletin site to which he said. The connection was reset I have no idea why!

 class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): print self.address_string() print "User ip:",self.client_address[0] print self.date_time_string()#return time print self.path print self.headers self.copyfile(urllib.urlopen(self.path), self.wfile) print "--------------------------------------------\n" #this is the function where is the problem def do_POST(self): print "=====================\n" print self.raw_requestline print self.headers.getheaders("Content-Length") length = int(self.headers.getheaders("Content-Length")[0]) post_data = urlparse.parse_qs(self.rfile.read(length)) self.copyfile(urllib.urlopen(self.path,urllib.urlencode(post_data)),self.wfile) print "=====================\n" 

hope i can get a hint of it

+4
source share

All Articles