Apache HttpClient5 – Как установить LocalAddress для каждого запроса?Apache

Anonymous
Apache HttpClient5 – Как установить LocalAddress для каждого запроса?

Сообщение Anonymous »


I'm migrating apache httpclient from 4.5 to 5.3 and my app currently chooses from a set of local ip's dynamically.

Example code:

HttpGet request = new HttpGet(url); request.setRequestConfig(RequestConfig.custom() .setLocalAddress(someLocalInetAddress) .build()); In httpclient 5.x the setLocalAddress() has been removed and I need a new way to assign the local address.

I know I can create ConnectionSocketFactory on the ConnectionManager level but this doesn't work for me because it would require explicit configuration for when to use each IP (as far as I understand). I have some other logic which determines the IP and I simply need to set it for the request.


Источник: https://stackoverflow.com/questions/781 ... er-request

Вернуться в «Apache»