You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2016/03/18 21:45:54 UTC

Re: svn commit: r1735672 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java

On 18 March 2016 at 20:17,  <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Fri Mar 18 20:17:05 2016
> New Revision: 1735672
>
> URL: http://svn.apache.org/viewvc?rev=1735672&view=rev
> Log:
> Isolate and document behaviour in case of redirect

It's a good idea to use a method to isolate the behaviour.
However I was hoping that the HTTP library would have an API to
provide that service.
Ideally JMeter should let the library just get on with the processing.

This isn't always possible - e.g. for cookies - but as far as possible
JMeter should not duplicate logic that's in the HTTP library.

> Modified:
>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1735672&r1=1735671&r2=1735672&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Fri Mar 18 20:17:05 2016
> @@ -1501,9 +1501,8 @@ public abstract class HTTPSamplerBase ex
>              }
>              // Change all but HEAD into GET (Bug 55450)
>              String method = lastRes.getHTTPMethod();
> -            if (!HTTPConstants.HEAD.equalsIgnoreCase(method)) {
> -                method = HTTPConstants.GET;
> -            }
> +            method = computeMethodForRedirect(method, res.getResponseCode());
> +
>              try {
>                  URL url = ConversionUtils.makeRelativeURL(lastRes.getURL(), location);
>                  url = ConversionUtils.sanitizeUrl(url).toURL();
> @@ -1568,6 +1567,21 @@ public abstract class HTTPSamplerBase ex
>      }
>
>      /**
> +     * See <a href="http://tools.ietf.org/html/rfc2616#section-10.3">RFC2616#section-10.3</a>
> +     * JMeter conforms currently to HttpClient 4.5.2 supported RFC
> +     * TODO Update when migrating to HttpClient 5.X
> +     * @param initialMethod the initial HTTP Method
> +     * @param responseCode String response code
> +     * @return the new HTTP Method as per RFC
> +     */
> +    private String computeMethodForRedirect(String initialMethod, String responseCode) {
> +        if (!HTTPConstants.HEAD.equalsIgnoreCase(initialMethod)) {
> +            return HTTPConstants.GET;
> +        }
> +        return initialMethod;
> +    }
> +
> +    /**
>       * Follow redirects and download page resources if appropriate. this works,
>       * but the container stuff here is what's doing it. followRedirects() is
>       * actually doing the work to make sure we have only one container to make
>
>