On Thu, 2019-01-10 at 14:05 +0000, Omar Alkhateeb wrote:
> I tried this but fails
> 
> CloseableHttpClient client =
> HttpClientBuilder.create().addInterceptorLast( 
>                         new HttpRequestInterceptor() {
>                             @Override
>                             public void process(final HttpRequest
> request, final HttpContext context)
>                                     throws HttpException, IOException
> {
>                                 final String PROXY_CONN_DIRECTIVE =
> "Proxy-Connection";
>                                 Args.notNull(request, "HTTP
> request");
> 
>                                 final String method =
> request.getRequestLine().getMethod();
>                                 if
> (method.equalsIgnoreCase("CONNECT")) 
>                                 {
>                                     request.setHeader(PROXY_CONN_DIRE
> CTIVE, org.apache.http.protocol.HTTP.CONN_KEEP_ALIVE);
>                                     request.setHeader("X-Forwarded-
> For", "10.52.106.89");
>                                     return;
>                                 }
>                             }
>                         }   
>                 )
>                 .setConnectionManager(connectionManager)
>                 .setRedirectStrategy(new LaxRedirectStrategy())
> //                //.setDefaultHeaders(defaultHeaders)
> //                //.setRoutePlanner(routePlanner)
>                 .build();
> 
> What do you thinks ?
> 
> Omar Khateeb | QA Engineer, IDA & DLP

That is certainly not what I suggested you should do

Oleg

> 
> -----Original Message-----
> From: Omar Alkhateeb [mailto:[email protected]] 
> Sent: Thursday, January 10, 2019 3:16 PM
> To: HttpComponents Project
> Subject: RE: Http CONNECT Method with XFF Header
> 
> I found this class, but can't edit because it is .class binary file
> 
> public class RequestClientConnControl implements
> HttpRequestInterceptor {
> 
>     private final Log log = LogFactory.getLog(getClass());
> 
>     private static final String PROXY_CONN_DIRECTIVE = "Proxy-
> Connection";
> 
>     public RequestClientConnControl() {
>         super();
>     }
> 
>     public void process(final HttpRequest request, final HttpContext
> context)
>             throws HttpException, IOException {
>         Args.notNull(request, "HTTP request");
> 
>         final String method = request.getRequestLine().getMethod();
>         if (method.equalsIgnoreCase("CONNECT")) {
>             request.setHeader(PROXY_CONN_DIRECTIVE,
> HTTP.CONN_KEEP_ALIVE);
>             return;
>         }
> 
> Omar Khateeb | QA Engineer, IDA & DLP
> Check Point Software Technologies | | [email protected]
> 
> 
> -----Original Message-----
> From: Omar Alkhateeb [mailto:[email protected]] 
> Sent: Thursday, January 10, 2019 3:15 PM
> To: HttpComponents Project
> Subject: RE: Http CONNECT Method with XFF Header
> 
> Hi Oleg,
> 
> Thanks for the response, Can you show me example of the steps you
> guided me, I can't find a way
> 
> Omar Khateeb | QA Engineer, IDA & DLP
> Check Point Software Technologies | | [email protected]
> 
> -----Original Message-----
> From: Oleg Kalnichevski [mailto:[email protected]] 
> Sent: Wednesday, January 09, 2019 6:38 PM
> To: HttpComponents Project
> Subject: Re: Http CONNECT Method with XFF Header
> 
> 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]
> 
> 
> Email secured by Check Point
> B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
> KKCB��[��X��ܚX�KK[XZ[
> �]�][��X��ܚX�P˘\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[
> �]�Z[˘\X�K�ܙ�B�
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to