0

When I make request to a url, I believe the ip address of the client is sent to the server. And in that case the ip address must be present in request header, or am I wrong?

So, I say

import requests    
resp = requests.get("http://localhost:8000/test")
print resp.request.headers

But I can't see any ip address when printing resp.request.headers, so how can I view the ip address of client. And if I can't see it as part of resp.request.headers, how does server get the ip address of the client if it isn't present in request header?

Akshar Raaj
  • 14,231
  • 7
  • 51
  • 45
  • http://stackoverflow.com/questions/22492484/how-do-i-get-the-ip-address-from-a-http-request-using-the-requests-library any help? – Paul Rooney Feb 15 '15 at 12:37

1 Answers1

5

IP address is not set by client, it is part of the connection. Quote from here:

(remote address) is taken from the ip address that hits the http server and not in the request. as if you are behind a proxy you would only see the ip of the proxy. it doesnt touch the http header data

A server gets a connection, natrually it also knows where it comes from.

laike9m
  • 18,344
  • 20
  • 107
  • 140