You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2018/03/06 16:20:05 UTC
svn commit: r1825998 - in /jmeter/trunk:
src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java
xdocs/changes.xml
Author: pmouawad
Date: Tue Mar 6 16:20:04 2018
New Revision: 1825998
URL: http://svn.apache.org/viewvc?rev=1825998&view=rev
Log:
Bug 61058 - HTTP Request : Deflate triggers "Unexpected end of ZLIB input stream"
Contributed by UbikLoadPack
Bugzilla Id: 61058
Added:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java (with props)
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
jmeter/trunk/xdocs/changes.xml
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=1825998&r1=1825997&r2=1825998&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 Tue Mar 6 16:20:04 2018
@@ -71,7 +71,6 @@ import org.apache.http.client.Credential
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.DeflateInputStream;
import org.apache.http.client.entity.InputStreamFactory;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -146,6 +145,7 @@ import org.apache.jmeter.protocol.http.c
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.DynamicKerberosSchemeFactory;
import org.apache.jmeter.protocol.http.control.HeaderManager;
+import org.apache.jmeter.protocol.http.sampler.hc.LaxDeflateInputStream;
import org.apache.jmeter.protocol.http.sampler.hc.LazyLayeredConnectionSocketFactory;
import org.apache.jmeter.protocol.http.util.EncoderCache;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
@@ -189,6 +189,8 @@ public class HTTPHC4Impl extends HTTPHCA
private static final int MAX_BODY_RETAIN_SIZE = JMeterUtils.getPropDefault("httpclient4.max_body_retain_size", 32 * 1024);
+ private static final boolean DEFLATE_RELAX_MODE = JMeterUtils.getPropDefault("httpclient4.deflate_relax_mode", false);
+
private static final Logger log = LoggerFactory.getLogger(HTTPHC4Impl.class);
private static final InputStreamFactory GZIP = new InputStreamFactory() {
@@ -201,7 +203,7 @@ public class HTTPHC4Impl extends HTTPHCA
private static final InputStreamFactory DEFLATE = new InputStreamFactory() {
@Override
public InputStream create(final InputStream instream) throws IOException {
- return new DeflateInputStream(instream);
+ return new LaxDeflateInputStream(instream, DEFLATE_RELAX_MODE);
}
};
Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java?rev=1825998&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java (added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java Tue Mar 6 16:20:04 2018
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.http.sampler.hc;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.http.client.entity.DeflateInputStream;
+import org.apache.http.client.entity.DeflateInputStreamFactory;
+
+/**
+ * {@link DeflateInputStreamFactory} subclass that has a flag to accept
+ * "edgy streams" that signal end of stream with {@link EOFException}
+ * which seems to be rather frequent
+ *
+ * @see https://bz.apache.org/bugzilla/show_bug.cgi?id=61058
+ * @since 4.1
+ */
+public class LaxDeflateInputStream extends DeflateInputStream {
+ private final boolean relax;
+
+ /**
+ * @param wrapped
+ * @param relax
+ * @throws IOException
+ */
+ public LaxDeflateInputStream(InputStream wrapped, boolean relax) throws IOException {
+ super(wrapped);
+ this.relax = relax;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.http.client.entity.DeflateInputStream#read(byte[], int, int)
+ */
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ try {
+ return super.read(b, off, len);
+ } catch (final EOFException ex) {
+ return handleRelaxMode(ex, relax);
+ }
+ }
+
+ @Override
+ public int read() throws IOException {
+ try {
+ return super.read();
+ } catch (final EOFException ex) {
+ return handleRelaxMode(ex, relax);
+ }
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ try {
+ return super.read(b);
+ } catch (final EOFException ex) {
+ return handleRelaxMode(ex, relax);
+ }
+ }
+
+ /**
+ * @param ex EOFException
+ * @param relaxMode relax mode enabled
+ * @return -1 if relax
+ * @throws EOFException
+ */
+ private int handleRelaxMode(final EOFException ex, final boolean relaxMode) throws EOFException {
+ if(relaxMode) {
+ return -1;
+ } else {
+ throw ex;
+ }
+ }
+}
Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxDeflateInputStream.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1825998&r1=1825997&r2=1825998&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Mar 6 16:20:04 2018
@@ -140,6 +140,7 @@ this behaviour, set <code>httpclient.res
<h3>HTTP Samplers and Test Script Recorder</h3>
<ul>
<li><bug>62114</bug>HTTP(S) Test Script Recorder : Client certificate authentication uses the first SSLManager created. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
+ <li><bug>61058</bug>HTTP Request : Deflate triggers "Unexpected end of ZLIB input stream". Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
</ul>
<h3>Other Samplers</h3>