Requests - Proxy

So far, we have seen clients directly connecting and talking to the server. Using proxy, the interaction happens as follows −

  • The client sends a request to the proxy.
  • The proxy sends the request to the server.
  • The server sends back the response to the proxy.
  • The proxy will send a response back to the client.

Using Http-proxy is additional security assigned to manage the data exchange between client and server. The requests libraries also have provision to handle proxy, by using the proxies param as shown below −


import requests
proxies = {
'http': 'http://localhost:8080'
res = requests.get('', proxies=proxies)

The request will route to http://localhost:8080 URL.


Kickstart Your Career

Get certified by completing the course

Get Started