On Wed, 2019-01-09 at 14:54 +0000, Omar Alkhateeb wrote:
> Hi All,
>
> As I noticed, there is no Class for HttpConnect method
>
> I need to add specific Http Header on CONNECT which is called X-For-
> Forward
>
> I can successfully add XFF Header on HttpGet Request using :
>
> HttpClientContext context = HttpClientContext.create();
> HttpGet httpget = new HttpGet(URL);
> RequestConfig requestConfig =
> RequestConfig.copy(defaultRequestConfig)
> .setProxy(new HttpHost(Proxy, Port))
> .build();
> httpget.setConfig(requestConfig);
> httpget.setHeader("X-Forwarded-For", XFFHeader);
> httpget.setHeader(new BasicHeader("Prama", "no-cache"));
> httpget.setHeader(new BasicHeader("Cache-Control", "no-cache"));
> httpget.setHeader("X-Requested-With", "XMLHttpRequest");
> httpget.setHeader(HttpHeaders.USER_AGENT,"Mozilla/5.0 (Windows NT
> 10.0; Win64; x64) "
> + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100
> Safari/537.36 Chrome/69.0.3497.100 "
> + "Apache-HttpClient/4.5.3 (Java/1.8.0_141)");
>
> Is there a way to Add the same Header to CONNECT method ?
>
It will not be pretty with HttpClient 4.5 but it can be done.
1. Subclass HttpClientBuilder
2. override #createMainExec method
https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java#L889
3. Hijack proxyHttpProcessor
Hope this helps
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]