I am trying to build a simple proxy server in Python that serves as the middle person that monitors and retrieves all the requests/traffic that is passed between my web browser and the Internet. I found the following code:
import SocketServer
import SimpleHTTPServer
import urllib
PORT = 1234
class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.copyfile(urllib.urlopen(self.path), self.wfile)
httpd = SocketServer.ForkingTCPServer(('', PORT), Proxy)
print "serving at port", PORT
httpd.serve_forever()
But the example only handles GET requests. Is there a way for the proxy server to handle the POST requests traffic from the browser as well? Thank you so much for your help! :)
just like you implemented do_GET
, you can also implement do_POST
in your Proxy
class. This should probably work. You can refer this .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.