jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1450262 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java xdocs/changes.xml
Date Tue, 26 Feb 2013 16:31:49 GMT
Author: sebb
Date: Tue Feb 26 16:31:48 2013
New Revision: 1450262

URL: http://svn.apache.org/r1450262
Log:
View Results Tree have a lot of Garbage characters if html page uses double-byte charset
Bugzilla Id: 54589

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java?rev=1450262&r1=1450261&r2=1450262&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
Tue Feb 26 16:31:48 2013
@@ -20,6 +20,7 @@ package org.apache.jmeter.protocol.http.
 
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.nio.charset.Charset;
 
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
 import org.apache.jmeter.samplers.SampleResult;
@@ -195,6 +196,7 @@ public class HTTPSampleResult extends Sa
             queryString = string;
         }
     }
+
     /**
      * Overrides the method from SampleResult - so the encoding can be extracted from
      * the Meta content-type if necessary.
@@ -204,12 +206,13 @@ public class HTTPSampleResult extends Sa
      * @return the dataEncoding value as a String
      */
     @Override
-    public String getDataEncodingWithDefault() {
-        if (getDataEncodingNoDefault() == null && getContentType().startsWith("text/html")){
// $NON-NLS-1$
+    public String getDataEncodingNoDefault() {
+        if (super.getDataEncodingNoDefault() == null && getContentType().startsWith("text/html")){
// $NON-NLS-1$
             byte[] bytes=getResponseData();
             // get the start of the file
-            // TODO - charset?
-            String prefix = new String(bytes,0,Math.min(bytes.length, 2000)).toLowerCase(java.util.Locale.ENGLISH);
+            String prefix = new String(bytes, 0, Math.min(bytes.length, 2000), 
+                                       Charset.forName(DEFAULT_HTTP_ENCODING))
+                                .toLowerCase(java.util.Locale.ENGLISH);
             // Extract the content-type if present
             final String METATAG = "<meta http-equiv=\"content-type\" content=\""; //
$NON-NLS-1$
             int tagstart=prefix.indexOf(METATAG);
@@ -217,13 +220,12 @@ public class HTTPSampleResult extends Sa
                 tagstart += METATAG.length();
                 int tagend = prefix.indexOf('\"', tagstart); // $NON-NLS-1$
                 if (tagend!=-1){
-                    // TODO use fixed charset:
-                    final String ct = new String(bytes,tagstart,tagend-tagstart); // TODO
- charset?
+                    final String ct = prefix.substring(tagstart,tagend);
                     setEncodingAndType(ct);// Update the dataEncoding
                 }
             }
         }
-        return super.getDataEncodingWithDefault(DEFAULT_ENCODING);
+        return super.getDataEncodingNoDefault();
     }
 
     public void setResponseNoContent(){

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1450262&r1=1450261&r2=1450262&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Feb 26 16:31:48 2013
@@ -106,7 +106,7 @@ This does not affect JMeter operation.
 
 <h3>Listeners</h3>
 <ul>
-<li><bugzilla>54589</bugzilla> - View Results Tree have a lot of Garbage
characters Garbage characters</li>
+<li><bugzilla>54589</bugzilla> - View Results Tree have a lot of Garbage
characters if html page uses double-byte charset</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>



Mime
View raw message