You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Kaushal Kothari <ka...@gmail.com> on 2020/04/16 10:50:22 UTC

'Host' header set to incorrect value upon receiving a 301 status response

Hi Team,

This is regarding an issue I am facing while using the Apache components
client 4.5.5.

My use case is as follows:

1. Http-client is configured to connect to http-server1 with host1 and port
8888. Both the http-client and the server1 are running on the same machine.

2. The http-server1 is suppose to give an 301 status code and is configured
with the location pointing to http-server2 with host2 and port 8888.
Http-server2 is running on a different machine.

3. When the Http-client receives this response from server1, it creates
another request with URI as mentioned in the "location" header but it still
uses the host1 for the request instead of host2.

4. As a result of this, the redirected http request fails with a 400 status
code.

Can you please help me in pointing out what might be causing this?  Can you
also suggest any method that can be used to change the host header in the
second request?

Thanks.
Kaushal.