Author: sebb
Date: Fri Mar 9 17:04:28 2007
New Revision: 516629
URL: http://svn.apache.org/viewvc?view=rev&rev=516629
Log:
Bug 41705 - add content-encoding option to HTTP samplers
Modified:
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
Modified:
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
Fri Mar 9 17:04:28 2007
@@ -100,6 +100,7 @@
constant_timer_delay=Thread Delay (in milliseconds)\:
constant_timer_memo=Add a constant delay between sampling
constant_timer_title=Constant Timer
+content_encoding=Content encoding\:
controller=Controller
cookie_manager_policy=Cookie Policy
cookie_manager_title=HTTP Cookie Manager
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
Fri Mar 9 17:04:28 2007
@@ -54,6 +54,8 @@
private static String PROTOCOL = "protocol"; // $NON-NLS-1$
+ private static String CONTENT_ENCODING = "content_encoding"; //
$NON-NLS-1$
+
private static String PATH = "path"; // $NON-NLS-1$
private static String FOLLOW_REDIRECTS = "follow_redirects"; //
$NON-NLS-1$
@@ -68,6 +70,8 @@
private JTextField protocol;
+ private JTextField contentEncoding;
+
private JTextField path;
private JCheckBox followRedirects;
@@ -96,9 +100,9 @@
path.setText(""); // $NON-NLS-1$
port.setText(""); // $NON-NLS-1$
protocol.setText(""); // $NON-NLS-1$
+ contentEncoding.setText(""); // $NON-NLS-1$
useKeepAlive.setSelected(true);
argsPanel.clear();
-
}
public TestElement createTestElement() {
@@ -113,6 +117,7 @@
element.setProperty(HTTPSamplerBase.PORT, port.getText());
element.setProperty(HTTPSamplerBase.PROTOCOL,
protocol.getText());
element.setProperty(HTTPSamplerBase.METHOD, method.getText());
+ element.setProperty(HTTPSamplerBase.CONTENT_ENCODING,
contentEncoding.getText());
element.setProperty(HTTPSamplerBase.PATH, path.getText());
element.setProperty(new
BooleanProperty(HTTPSamplerBase.FOLLOW_REDIRECTS,
followRedirects.isSelected()));
element.setProperty(new
BooleanProperty(HTTPSamplerBase.AUTO_REDIRECTS, autoRedirects.isSelected()));
@@ -141,6 +146,7 @@
}
protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
method.setText(el.getPropertyAsString(HTTPSamplerBase.METHOD));
+
contentEncoding.setText(el.getPropertyAsString(HTTPSamplerBase.CONTENT_ENCODING));
path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
followRedirects.setSelected(((AbstractTestElement)
el).getPropertyAsBoolean(HTTPSamplerBase.FOLLOW_REDIRECTS));
@@ -251,9 +257,14 @@
// PROTOCOL
protocol = new JTextField(20);
protocol.setName(PROTOCOL);
+ // CONTENT_ENCODING
+ contentEncoding = new JTextField(10);
+ contentEncoding.setName(CONTENT_ENCODING);
JLabel protocolLabel = new
JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
protocolLabel.setLabelFor(protocol);
+ JLabel contentEncodingLabel = new
JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
+ protocolLabel.setLabelFor(contentEncoding);
method = new JLabeledChoice(JMeterUtils.getResString("method"), //
$NON-NLS-1$
HTTPSamplerBase.getValidMethodsAsArray());
@@ -265,6 +276,10 @@
panel.add(method);
panel.setMinimumSize(panel.getPreferredSize());
+ panel.add(Box.createHorizontalStrut(5));
+
+ panel.add(contentEncodingLabel);
+ panel.add(contentEncoding);
return panel;
}
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Fri Mar 9 17:04:28 2007
@@ -222,7 +222,7 @@
public HTTPSampler2() {
}
- /**
+ /*
* Send POST data from <code>Entry</code> to the open connection.
*
* @param connection
@@ -233,6 +233,7 @@
private void sendPostData(PostMethod post) throws IOException {
// If filename was specified then send the post using multipart
syntax
String filename = getFilename();
+ final String contentEncoding = getContentEncoding();
if ((filename != null) && (filename.trim().length() > 0)) {
if (getSendFileAsPostBody()) {
post.setRequestEntity(new FileRequestEntity(new
File(filename),null));
@@ -251,6 +252,11 @@
post.setRequestEntity(new MultipartRequestEntity(parts,
post.getParams()));
}
} else {
+ // If a content encoding is specified, we set it as http
parameter, so that
+ // the post body will be encoded in the specified content encoding
+ if(contentEncoding != null && contentEncoding.trim().length() > 0)
{
+ post.getParams().setContentCharset(contentEncoding);
+ }
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
Argument arg = (Argument) args.next().getObjectValue();
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Fri Mar 9 17:04:28 2007
@@ -82,6 +82,8 @@
public final static String METHOD = "HTTPSampler.method"; // $NON-NLS-1$
+ public final static String CONTENT_ENCODING =
"HTTPSampler.contentEncoding"; // $NON-NLS-1$
+
public final static String IMPLEMENTATION = "HTTPSampler.implementation";
// $NON-NLS-1$
public final static String PATH = "HTTPSampler.path"; // $NON-NLS-1$
@@ -341,6 +343,14 @@
public String getMethod() {
return getPropertyAsString(METHOD);
+ }
+
+ public void setContentEncoding(String value) {
+ setProperty(CONTENT_ENCODING, value);
+ }
+
+ public String getContentEncoding() {
+ return getPropertyAsString(CONTENT_ENCODING);
}
public void setUseKeepAlive(boolean value) {
Modified:
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
---
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
(original)
+++
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
Fri Mar 9 17:04:28 2007
@@ -23,7 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URLConnection;
@@ -87,8 +87,14 @@
// No filename specified, so send the post using normal syntax
else {
String postData = sampler.getQueryString();
- PrintWriter out = new
PrintWriter(connection.getOutputStream());
- out.print(postData);
+ final String contentEncoding =
sampler.getContentEncoding();
+ OutputStreamWriter out;
+ if (contentEncoding.length() > 0) {
+ out = new
OutputStreamWriter(connection.getOutputStream(), contentEncoding);
+ } else {
+ out = new
OutputStreamWriter(connection.getOutputStream());
+ }
+ out.write(postData);
out.flush();
out.close();
}
Modified: jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml?view=diff&rev=516629&r1=516628&r2=516629
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml Fri Mar 9 17:04:28 2007
@@ -78,6 +78,7 @@
<li>Bug 41707 - HTTP Proxy XML-RPC support</li>
<li>Bug 40381 - LDAP: more descriptive strings</li>
<li>Bug 40369 (partial) Equals Response Assertion</li>
+<li>Bug 41705 - add content-encoding option to HTTP samplers</li>
</ul>
<h4>Non-functional improvements:</h4>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]