Question

I am making a HTTP url call using RestTemplate with the below simple code. Here url is one of our Service which will be extracting IP Address from the header.

String response = restTemplate.getForObject(url, String.class);

So my question is does the IP Address also gets passed in the HTTP Header while making the url call or not in the way I am doing as shown above?

My service is running on machineB so if I am hitting that url from machineA using the above RestTemplate code does machineA IP Address gets passed in the header or not?

Or Do we need to do any extra stuff to pass the IP Address in the header while making the url call?

Was it helpful?

Solution

The IP address of the client is not automatically passed in an HTTP standard header, as the HTTP server would have no need for this information. The IP address of the client is already available to the server via the IP packets used to transport the HTTP request.

If you want to have the client send it's IP address in an HTTP header you will have to create a custom header and fill it in with each request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top