Author: sebb
Date: Tue Oct 23 17:01:13 2007
New Revision: 587702
URL: http://svn.apache.org/viewvc?rev=587702&view=rev
Log:
Bug 43678 - Handle META tag http-equiv charset
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
jakarta/jmeter/trunk/xdocs/changes.xml
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java?rev=587702&r1=587701&r2=587702&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
Tue Oct 23 17:01:13 2007
@@ -164,5 +164,31 @@
queryString = string;
}
}
-
+ /**
+ * Overrides the method from SampleResult - so the encoding can be
extracted from
+ * the Meta content-type if necessary.
+ *
+ * Updates the dataEncoding field if the content-type is found.
+ *
+ * @return the dataEncoding value as a String
+ */
+ public String getDataEncodingWithDefault() {
+ if (getDataEncodingNoDefault() == null &&
getContentType().startsWith("text/html")){ // $NON-NLS-1$
+ byte[] bytes=getResponseData();
+ // get the start of the file
+ String prefix = new String(bytes,0,Math.min(bytes.length,
1000)).toLowerCase();
+ // Extract the content-type if present
+ final String METATAG = "<meta http-equiv=\"content-type\"
content=\""; // $NON-NLS-1$
+ int tagstart=prefix.indexOf(METATAG);
+ if (tagstart!=-1){
+ tagstart += METATAG.length();
+ int tagend = prefix.indexOf("\"", tagstart); //
$NON-NLS-1$
+ if (tagend!=-1){
+ final String ct = new
String(bytes,tagstart,tagend-tagstart);
+ setEncodingAndType(ct);// Update the
dataEncoding
+ }
+ }
+ }
+ return super.getDataEncodingWithDefault();
+ }
}
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=587702&r1=587701&r2=587702&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Oct 23 17:01:13 2007
@@ -80,6 +80,7 @@
<li>Added -G option to set properties in remote servers</li>
<li>Added -X option to stop remote servers after non-GUI run</li>
<li>Bug 43485 - Ability to specify keep-alive on SOAP/XML-RPC request</li>
+<li>Bug 43678 - Handle META tag http-equiv charset</li>
</ul>
<h4>Non-functional Improvements</h4>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]