jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: svn commit: r1396754 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Date Wed, 10 Oct 2012 20:46:16 GMT
Thank you sebb.


By the way shouldn't we implement something like this:
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d5e281


Regards
Philippe

On Wed, Oct 10, 2012 at 10:28 PM, sebb <sebbaz@gmail.com> wrote:

> On 10 October 2012 20:31,  <pmouawad@apache.org> wrote:
> > Author: pmouawad
> > Date: Wed Oct 10 19:31:49 2012
> > New Revision: 1396754
> >
> > URL: http://svn.apache.org/viewvc?rev=1396754&view=rev
> > Log:
> > Add comment
> > Remove now useless code as httpclient 4.2.1 has been integrated which
> contains fix for:
> > https://issues.apache.org/jira/browse/HTTPCLIENT-1120
> >
> > Modified:
> >
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> >
> > Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> > URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1396754&r1=1396753&r2=1396754&view=diff
> >
> ==============================================================================
> > ---
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> (original)
> > +++
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> Wed Oct 10 19:31:49 2012
> > @@ -384,12 +384,20 @@ public class HTTPHC4Impl extends HTTPHCA
> >
> >          private final int hashCode; // Always create hash because we
> will always need it
> >
> > -        public HttpClientKey(URL url, boolean b, String proxyHost,
> > +        /**
> > +         * @param url URL Only protocol and url authority are used
> (protocol://[user:pass@]host:[port])
> > +         * @param hasProxy has proxy
> > +         * @param proxyHost proxy host
> > +         * @param proxyPort proxy port
> > +         * @param proxyUser proxy user
> > +         * @param proxyPass proxy password
> > +         */
> > +        public HttpClientKey(URL url, boolean hasProxy, String
> proxyHost,
> >                  int proxyPort, String proxyUser, String proxyPass) {
> >              // N.B. need to separate protocol from authority otherwise
> http://server would match https://erver
> >              // could use separate fields, but simpler to combine them
> >              this.target = url.getProtocol()+"://"+url.getAuthority();
> > -            this.hasProxy = b;
> > +            this.hasProxy = hasProxy;
> >              this.proxyHost = proxyHost;
> >              this.proxyPort = proxyPort;
> >              this.proxyUser = proxyUser;
> > @@ -469,49 +477,7 @@ public class HTTPHC4Impl extends HTTPHCA
> >
> >              HttpParams clientParams = new DefaultedHttpParams(new
> BasicHttpParams(), DEFAULT_HTTP_PARAMS);
> >
> > -            httpClient = new DefaultHttpClient(clientParams){
> > -                @Override
> > -                protected HttpRequestRetryHandler
> createHttpRequestRetryHandler() {
> > -                    return new
> DefaultHttpRequestRetryHandler(RETRY_COUNT, false) {
>
> Only the retryRequest override is the hack.
>
> > -                        // TODO HACK to fix
> https://issues.apache.org/jira/browse/HTTPCLIENT-1120
> > -                        // can hopefully be removed when 4.1.3 or 4.2
> are released
> > -                        @Override
> > -                        public boolean retryRequest(IOException ex, int
> count, HttpContext ctx) {
> > -                            Object request =
> ctx.getAttribute(ExecutionContext.HTTP_REQUEST);
> > -                            if(request instanceof HttpUriRequest){
> > -                                if (request instanceof RequestWrapper) {
> > -                                    request = ((RequestWrapper)
> request).getOriginal();
> > -                                }
> > -
>  if(((HttpUriRequest)request).isAborted()){
> > -                                    log.warn("Workround for
> HTTPCLIENT-1120 request retry: "+ex);
> > -                                    return false;
> > -                                }
> > -                            }
> > -                            /*
> > -                             * When connect fails due to abort, the
> request is not in the context.
> > -                             * Tried adding the request - with a new
> key - to the local context in the sample() method,
> > -                             * but the request was not flagged as
> aborted, so that did not help.
> > -                             * So we check for any specific exception
> that is triggered.
> > -                             */
> > -                            if (
> > -                                   (ex instanceof
> java.net.BindException &&
> > -                                    ex.getMessage().contains("Address
> already in use: connect"))
> > -                                ||
> > -                                    ex.getMessage().contains("Request
> aborted") // plain IOException
> > -                                ) {
> > -                                /*
> > -                                 * The above messages may be generated
> by aborted connects.
> > -                                 * If either occurs in other
> situations, retrying is unlikely to help,
> > -                                 * so preventing retry should not cause
> a problem.
> > -                                */
> > -                                log.warn("Workround for HTTPCLIENT-1120
> connect retry: "+ex);
> > -                                return false;
> > -                            }
> > -                            return super.retryRequest(ex, count, ctx);
> > -                        } // end of hack
>
> Deleted too much; the retry count part is still needed.
>
> > -                    }; // set retry count
> > -                }
> > -            };
> > +            httpClient = new DefaultHttpClient(clientParams);
> >              ((AbstractHttpClient)
> httpClient).addResponseInterceptor(new ResponseContentEncoding());
> >              ((AbstractHttpClient)
> httpClient).addResponseInterceptor(METRICS_SAVER); // HACK
> >              ((AbstractHttpClient)
> httpClient).addRequestInterceptor(METRICS_RESETTER);
> >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message