java - how to set request hostname in httpclient -


i use apache httpclient send request site, site check servlet request hostname. checks hostname this:

string hostname = request.getremotehost(); 

and when send request, hostname ip address, not hostname. send request code this:

httpclientbuilder httpclientbuilder = httpclientbuilder.create(); list<header> headerlist = new arraylist<>(); headerlist.add(new basicheader("host","mycustomhostname")); httpclientbuilder client = httpclientbuilder.build(); httpget request = new httpget("http://siteaddress:8080/gethostname"); request.setheader(new basicheader("host","mycustomhostnameagain.just.for.try")); client.execute(request); 

but not works.

how set request hostname in httpclient? thx.

request.getremotehost() not use headers http request. instead doing reverse dns lookup. takes ip got request , tries dns information. possible that information doesn't exist in case call returns ip address string.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -