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/05/11 21:15:49 UTC
Re: svn commit: r1743429 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
On 11 May 2016 at 22:09, <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Wed May 11 21:09:00 2016
> New Revision: 1743429
>
> URL: http://svn.apache.org/viewvc?rev=1743429&view=rev
> Log:
> Bug 59489 - Regression in JMeter 3.0 : Compressed responses break keepalive management
> Bugzilla Id: 59489
>
> 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=1743429&r1=1743428&r2=1743429&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 May 11 21:09:00 2016
> @@ -186,10 +186,6 @@ public class HTTPHC4Impl extends HTTPHCA
> }
> };
>
> - /**
> - * Attribute name used to store headers in {@link BasicHttpContext}
> - */
> - private static final String JMETER_RESPONSE_BACKUP_HEADERS = "__jmeter.RESPONSE_BACKUP_HEADERS";
>
> /**
> * Headers to save
> @@ -209,8 +205,8 @@ public class HTTPHC4Impl extends HTTPHCA
> @Override
> public void process(HttpResponse response, HttpContext context)
> throws HttpException, IOException {
> + ArrayList<Header[]> headersToSave = new ArrayList<>(3);
>
> - context.removeAttribute(JMETER_RESPONSE_BACKUP_HEADERS);
> final HttpEntity entity = response.getEntity();
> final HttpClientContext clientContext = HttpClientContext.adapt(context);
> final RequestConfig requestConfig = clientContext.getRequestConfig();
> @@ -218,17 +214,21 @@ public class HTTPHC4Impl extends HTTPHCA
> if (requestConfig.isContentCompressionEnabled() && entity != null && entity.getContentLength() != 0) {
> final Header ceheader = entity.getContentEncoding();
> if (ceheader != null) {
> - ArrayList<Header[]> headersToSave = new ArrayList<>(3);
> for(String name : HEADERS_TO_SAVE) {
> Header[] hdr = response.getHeaders(name); // empty if none
> headersToSave.add(hdr);
> }
> - context.setAttribute(JMETER_RESPONSE_BACKUP_HEADERS, headersToSave);
> }
> }
>
> // Now invoke original parent code
> super.process(response, clientContext);
> + // Should this be in a finally ?
> + for (Header[] headers : headersToSave) {
> + for (Header headerToRestore : headers) {
> + response.addHeader(headerToRestore);
That can result in header duplication. See below.
> + }
> + }
> }
> };
>
> @@ -953,18 +953,6 @@ public class HTTPHC4Impl extends HTTPHCA
> for (Header responseHeader : rh) {
> writeResponseHeader(headerBuf, responseHeader);
> }
> - List<Header[]> backupHeaders = (List<Header[]>) localContext.getAttribute(JMETER_RESPONSE_BACKUP_HEADERS);
> - if(backupHeaders != null) {
> - for (Header[] headers : backupHeaders) {
> - for (Header responseHeader: headers) {
> - if (response.containsHeader(responseHeader.getName())) {
> - break; // it was not deleted, so don't store it again
Note that the original fix checks whether or not to restore the header.
> - }
> - writeResponseHeader(headerBuf, responseHeader);
> - }
> - }
> - }
> -
> return headerBuf.toString();
> }
>
>
>
Re: svn commit: r1743429 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Posted by Philippe Mouawad <ph...@gmail.com>.
thanks for review.
Feel free to commit the fix
On Wednesday, May 11, 2016, sebb <se...@gmail.com> wrote:
> On 11 May 2016 at 22:09, <pmouawad@apache.org <javascript:;>> wrote:
> > Author: pmouawad
> > Date: Wed May 11 21:09:00 2016
> > New Revision: 1743429
> >
> > URL: http://svn.apache.org/viewvc?rev=1743429&view=rev
> > Log:
> > Bug 59489 - Regression in JMeter 3.0 : Compressed responses break
> keepalive management
> > Bugzilla Id: 59489
> >
> > 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=1743429&r1=1743428&r2=1743429&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 May 11 21:09:00 2016
> > @@ -186,10 +186,6 @@ public class HTTPHC4Impl extends HTTPHCA
> > }
> > };
> >
> > - /**
> > - * Attribute name used to store headers in {@link BasicHttpContext}
> > - */
> > - private static final String JMETER_RESPONSE_BACKUP_HEADERS =
> "__jmeter.RESPONSE_BACKUP_HEADERS";
> >
> > /**
> > * Headers to save
> > @@ -209,8 +205,8 @@ public class HTTPHC4Impl extends HTTPHCA
> > @Override
> > public void process(HttpResponse response, HttpContext context)
> > throws HttpException, IOException {
> > + ArrayList<Header[]> headersToSave = new ArrayList<>(3);
> >
> > - context.removeAttribute(JMETER_RESPONSE_BACKUP_HEADERS);
> > final HttpEntity entity = response.getEntity();
> > final HttpClientContext clientContext =
> HttpClientContext.adapt(context);
> > final RequestConfig requestConfig =
> clientContext.getRequestConfig();
> > @@ -218,17 +214,21 @@ public class HTTPHC4Impl extends HTTPHCA
> > if (requestConfig.isContentCompressionEnabled() && entity
> != null && entity.getContentLength() != 0) {
> > final Header ceheader = entity.getContentEncoding();
> > if (ceheader != null) {
> > - ArrayList<Header[]> headersToSave = new
> ArrayList<>(3);
> > for(String name : HEADERS_TO_SAVE) {
> > Header[] hdr = response.getHeaders(name); //
> empty if none
> > headersToSave.add(hdr);
> > }
> > - context.setAttribute(JMETER_RESPONSE_BACKUP_HEADERS,
> headersToSave);
> > }
> > }
> >
> > // Now invoke original parent code
> > super.process(response, clientContext);
> > + // Should this be in a finally ?
> > + for (Header[] headers : headersToSave) {
> > + for (Header headerToRestore : headers) {
> > + response.addHeader(headerToRestore);
>
> That can result in header duplication. See below.
>
> > + }
> > + }
> > }
> > };
> >
> > @@ -953,18 +953,6 @@ public class HTTPHC4Impl extends HTTPHCA
> > for (Header responseHeader : rh) {
> > writeResponseHeader(headerBuf, responseHeader);
> > }
> > - List<Header[]> backupHeaders = (List<Header[]>)
> localContext.getAttribute(JMETER_RESPONSE_BACKUP_HEADERS);
> > - if(backupHeaders != null) {
> > - for (Header[] headers : backupHeaders) {
> > - for (Header responseHeader: headers) {
> > - if
> (response.containsHeader(responseHeader.getName())) {
> > - break; // it was not deleted, so don't store it
> again
>
> Note that the original fix checks whether or not to restore the header.
>
> > - }
> > - writeResponseHeader(headerBuf, responseHeader);
> > - }
> > - }
> > - }
> > -
> > return headerBuf.toString();
> > }
> >
> >
> >
>
--
Cordialement.
Philippe Mouawad.