diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java index bb0ce92879e..316a31022f3 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java @@ -263,6 +263,9 @@ private static String computePostBody(Arguments arguments, boolean crlfToLF) { StringBuilder postBody = new StringBuilder(); for (JMeterProperty argument : arguments) { HTTPArgument arg = (HTTPArgument) argument.getObjectValue(); + if (!arg.isEnabled()) { + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } String value = arg.getValue(); if (crlfToLF) { value = value.replaceAll("\r\n", "\n"); // See modifyTestElement diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java index 1f4af2befa2..02c68ee973f 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java @@ -39,12 +39,15 @@ /** * A GUI panel allowing the user to enter HTTP Parameters. * These have names and values, as well as check-boxes to determine whether or not to - * include the "=" sign in the output and whether or not to encode the output. + * include the "=" sign in the output and whether or not to encode the output and + * whether or not to enable them. */ public class HTTPArgumentsPanel extends ArgumentsPanel { private static final long serialVersionUID = 240L; + private static final String ENABLE = "enable"; //$NON-NLS-1$ + private static final String ENCODE_OR_NOT = "encode?"; //$NON-NLS-1$ private static final String INCLUDE_EQUALS = "include_equals"; //$NON-NLS-1$ @@ -60,21 +63,23 @@ public class HTTPArgumentsPanel extends ArgumentsPanel { @Override protected void initializeTableModel() { tableModel = new ObjectTableModel(new String[] { - ArgumentsPanel.COLUMN_RESOURCE_NAMES_0, ArgumentsPanel.COLUMN_RESOURCE_NAMES_1, ENCODE_OR_NOT, CONTENT_TYPE, INCLUDE_EQUALS }, + ENABLE, ArgumentsPanel.COLUMN_RESOURCE_NAMES_0, ArgumentsPanel.COLUMN_RESOURCE_NAMES_1, ENCODE_OR_NOT, CONTENT_TYPE, INCLUDE_EQUALS }, HTTPArgument.class, new Functor[] { + new Functor("isEnabled"), //$NON-NLS-1$ new Functor("getName"), //$NON-NLS-1$ new Functor("getValue"), //$NON-NLS-1$ new Functor("isAlwaysEncoded"), //$NON-NLS-1$ new Functor("getContentType"), //$NON-NLS-1$ new Functor("isUseEquals") }, //$NON-NLS-1$ new Functor[] { + new Functor("setEnabled"), //$NON-NLS-1$ new Functor("setName"), //$NON-NLS-1$ new Functor("setValue"), //$NON-NLS-1$ new Functor("setAlwaysEncoded"), //$NON-NLS-1$ new Functor("setContentType"), new Functor("setUseEquals")}, //$NON-NLS-1$ - new Class[] {String.class, String.class, Boolean.class, String.class, Boolean.class }); + new Class[] {Boolean.class, String.class, String.class, Boolean.class, String.class, Boolean.class }); } public static boolean testFunctors(){ @@ -85,6 +90,7 @@ public static boolean testFunctors(){ @Override protected void sizeColumns(JTable table) { + GuiUtils.fixSize(table.getColumn(ENABLE), table); GuiUtils.fixSize(table.getColumn(INCLUDE_EQUALS), table); GuiUtils.fixSize(table.getColumn(ENCODE_OR_NOT), table); } diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java index bc4478eecb3..c042ed6f801 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java @@ -1577,6 +1577,9 @@ protected String setupHttpEntityEnclosingRequestData(HttpEntityEnclosingRequestB if (arg.isSkippable(parameterName)) { continue; } + if (!arg.isEnabled()) { + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } ContentType contentType; if (arg.getContentType().indexOf(';') >= 0) { // assume, that the content type contains charset info @@ -1655,6 +1658,9 @@ else if(ADD_CONTENT_TYPE_TO_POST_IF_MISSING) { StringBuilder postBody = new StringBuilder(); for (JMeterProperty jMeterProperty : getArguments()) { HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); + if (!arg.isEnabled()) { + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } postBody.append(arg.getEncodedValue(contentEncoding)); } // Let StringEntity perform the encoding @@ -1807,6 +1813,9 @@ private UrlEncodedFormEntity createUrlEncodedFormEntity(final String urlContentE if (arg.isSkippable(parameterName)) { continue; } + if (!arg.isEnabled()) { + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } String parameterValue = arg.getValue(); if (!arg.isAlwaysEncoded()) { // The value is already encoded by the user diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java index 3b3b37d0141..91ed064a1f9 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java @@ -1189,6 +1189,9 @@ public String getQueryString(final String contentEncoding) { if (encodedName.isEmpty()) { continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists) } + if(!item.isEnabled()){ + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } if (!first) { buf.append(QRY_SEP); } else { diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/PutWriter.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/PutWriter.java index d6f5c87cd59..6419919b01f 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/PutWriter.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/PutWriter.java @@ -86,6 +86,9 @@ else if(sampler.getSendParameterValuesAsPostBody()) { StringBuilder putBodyBuffer = new StringBuilder(); for (JMeterProperty jMeterProperty : sampler.getArguments()) { HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue(); + if (!arg.isEnabled()) { + continue; // Skip parameters if they've been disabled from GUI using the checkbox + } putBodyBuffer.append(arg.getEncodedValue(contentEncoding)); } diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPArgument.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPArgument.java index 3353589b1f8..e73f40a0494 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPArgument.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPArgument.java @@ -134,7 +134,7 @@ public HTTPArgument(String name, String value, boolean alreadyEncoded) { } /** - * Construct a new HTTPArgument instance; alwaysEncoded is set to true. + * Construct a new HTTPArgument instance; enabled and alwaysEncoded set to true. * * @param name the name of the parameter * @param value the value of the parameter @@ -142,6 +142,7 @@ public HTTPArgument(String name, String value, boolean alreadyEncoded) { * @param contentEncoding the encoding used for the parameter value */ public HTTPArgument(String name, String value, boolean alreadyEncoded, String contentEncoding) { + setEnabled(true); setAlwaysEncoded(true); if (alreadyEncoded) { try {