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/10/19 20:04:25 UTC
svn commit: r1844375 - in /jmeter/trunk: bin/
src/protocol/http/org/apache/jmeter/protocol/http/sampler/
src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/ xdocs/
xdocs/usermanual/
Author: pmouawad
Date: Fri Oct 19 20:04:24 2018
New Revision: 1844375
URL: http://svn.apache.org/viewvc?rev=1844375&view=rev
Log:
Bug 62840 - HTTP Request : Add option httpclient4.gzip_relax_mode to avoid error when unzipping what seems to be invalid streams
Bugzilla Id: 62840
Added:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java (with props)
Modified:
jmeter/trunk/bin/jmeter.properties
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/properties_reference.xml
Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1844375&r1=1844374&r2=1844375&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Fri Oct 19 20:04:24 2018
@@ -434,6 +434,14 @@ remote_hosts=127.0.0.1
# Bigger results will be clipped.
#httpclient4.max_body_retain_size=32768
+# Ignore EOFException that some edgy application may emit to signal end of GZIP stream
+# Defaults to false
+#httpclient4.gzip_relax_mode=false
+
+# Ignore EOFException that some edgy application may emit to signal end of Deflated stream
+# Defaults to false
+#httpclient4.deflate_relax_mode=false
+
#---------------------------------------------------------------------------
# HTTP Cache Manager configuration
#---------------------------------------------------------------------------
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=1844375&r1=1844374&r2=1844375&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 Fri Oct 19 20:04:24 2018
@@ -41,7 +41,6 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.regex.Pattern;
-import java.util.zip.GZIPInputStream;
import javax.security.auth.Subject;
@@ -144,6 +143,7 @@ import org.apache.jmeter.protocol.http.c
import org.apache.jmeter.protocol.http.control.DynamicSPNegoSchemeFactory;
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.LaxGZIPInputStream;
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;
@@ -185,6 +185,8 @@ public class HTTPHC4Impl extends HTTPHCA
private static final String CONTEXT_ATTRIBUTE_METRICS = "__jmeter.M__";
+ private static final boolean GZIP_RELAX_MODE = JMeterUtils.getPropDefault("httpclient4.gzip_relax_mode", false);
+
private static final boolean DEFLATE_RELAX_MODE = JMeterUtils.getPropDefault("httpclient4.deflate_relax_mode", false);
private static final Logger log = LoggerFactory.getLogger(HTTPHC4Impl.class);
@@ -192,7 +194,7 @@ public class HTTPHC4Impl extends HTTPHCA
private static final InputStreamFactory GZIP = new InputStreamFactory() {
@Override
public InputStream create(final InputStream instream) throws IOException {
- return new GZIPInputStream(instream);
+ return new LaxGZIPInputStream(instream, GZIP_RELAX_MODE);
}
};
Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java?rev=1844375&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java (added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java Fri Oct 19 20:04:24 2018
@@ -0,0 +1,90 @@
+/*
+ * 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 java.util.zip.GZIPInputStream;
+
+/**
+ * {@link GZIPInputStream} subclass that has a flag to accept
+ * "edgy streams" that signal end of stream with {@link EOFException}
+ * which seems to be rather frequent
+ *
+ * @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=61058">Bugzilla 61058</a>
+ * @since 5.0
+ */
+public class LaxGZIPInputStream extends GZIPInputStream {
+ private final boolean relax;
+
+ /**
+ * @param wrapped the InputStream that should be wrapped
+ * @param relax flag to enable relaxed mode
+ * @throws IOException when super class throws an IOException
+ */
+ public LaxGZIPInputStream(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/LaxGZIPInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/hc/LaxGZIPInputStream.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1844375&r1=1844374&r2=1844375&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Oct 19 20:04:24 2018
@@ -76,6 +76,7 @@ Summary
<h3>HTTP Samplers and Test Script Recorder</h3>
<ul>
+ <li><bug>62840</bug>HTTP Request : Add option httpclient4.gzip_relax_mode to avoid error when unzipping what seems to be invalid streams</li>
</ul>
<h3>Other samplers</h3>
Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1844375&r1=1844374&r2=1844375&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Fri Oct 19 20:04:24 2018
@@ -535,6 +535,14 @@ JMETER-SERVER</source>
Bigger results will be clipped.<br/>
Defaults to: <code>327678</code> (bytes)
</property>
+<property name="httpclient4.deflate_relax_mode">
+ Ignore EOFException that some edgy application may emit to signal end of Deflated stream.<br/>
+ Defaults to: <code>false</code>
+</property>
+<property name="httpclient4.gzip_relax_mode">
+ Ignore EOFException that some edgy application may emit to signal end of GZipped stream.<br/>
+ Defaults to: <code>false</code>
+</property>
</properties>
</section>