You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2007/11/24 18:59:24 UTC

svn commit: r597899 - in /jakarta/jmeter/trunk: bin/jmeter.properties docs/changes.html src/core/org/apache/jmeter/samplers/SampleResult.java xdocs/changes.xml

Author: sebb
Date: Sat Nov 24 09:59:23 2007
New Revision: 597899

URL: http://svn.apache.org/viewvc?rev=597899&view=rev
Log:
Fix SampleResult dataType checking to better detect TEXT documents
Allow optional specification of addition TEXT content-types

Modified:
    jakarta/jmeter/trunk/bin/jmeter.properties
    jakarta/jmeter/trunk/docs/changes.html
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: jakarta/jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=597899&r1=597898&r2=597899&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/jmeter.properties (original)
+++ jakarta/jmeter/trunk/bin/jmeter.properties Sat Nov 24 09:59:23 2007
@@ -600,6 +600,11 @@
 #Should JMeter expand the tree when loading a test plan?
 #onload.expandtree=false
 
+# List of additional content types to be treated as text; separate entries with commas.
+# If the content type begins with the same string, then it is treated as text.
+# The following example types are already allowed for:
+#content-type_text=text/,application/javascript,application/json,application/xhtml+xml
+
 # Should JMeter automatically load additional JMeter properties?
 # File name to look for (comment to disable)
 user.properties=user.properties

Modified: jakarta/jmeter/trunk/docs/changes.html
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/changes.html?rev=597899&r1=597898&r2=597899&view=diff
==============================================================================
--- jakarta/jmeter/trunk/docs/changes.html (original)
+++ jakarta/jmeter/trunk/docs/changes.html Sat Nov 24 09:59:23 2007
@@ -374,6 +374,11 @@
 						</li>
 									
 
+												<li	>
+								Fix SampleResult dataType checking to better detect TEXT documents
+						</li>
+									
+
 						</ul>
 							  									 				<h4	>
 								Improvements
@@ -587,6 +592,11 @@
 
 												<li	>
 								Added Collapse All and Expand All Option menu items
+						</li>
+									
+
+												<li	>
+								Allow optional definition of extra content-types that are viewable as text
 						</li>
 									
 

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=597899&r1=597898&r2=597899&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Sat Nov 24 09:59:23 2007
@@ -555,10 +555,9 @@
     public void setEncodingAndType(String ct){
         if (ct != null) {
             // Extract charset and store as DataEncoding
-            // TODO do we need process http-equiv META tags, e.g.:
-            // <META http-equiv="content-type" content="text/html;
-            // charset=foobar">
-            // or can we leave that to the renderer ?
+            // N.B. The meta tag:
+            // <META http-equiv="content-type" content="text/html; charset=foobar">
+        	// is now processed by HTTPSampleResult#getDataEncodingWithDefault
             final String CS_PFX = "charset="; // $NON-NLS-1$
             int cset = ct.toLowerCase().indexOf(CS_PFX);
             if (cset >= 0) {
@@ -571,14 +570,45 @@
 				    setDataEncoding(charSet);
                 }
             }
-            if (ct.startsWith("image/")) {// $NON-NLS-1$
-                setDataType(BINARY);
-            } else {
+            if (isTextType(ct)) {
                 setDataType(TEXT);
+            } else {
+                setDataType(BINARY);
             }
         }
     }
 
+    // List of types that can be processed as text
+    private static final String[] TEXT_TYPES = {
+    	"text/",                  //$NON-NLS-1$
+    	"application/javascript", //$NON-NLS-1$
+    	"application/json",       //$NON-NLS-1$
+    	"application/xhtml+xml",  //$NON-NLS-1$
+        };
+ 
+    // Additional types as needed
+    private static final String[] TEXT_TYPES_OPT =
+    	JOrphanUtils.split(JMeterUtils.getPropDefault("content-type_text", ""), ","); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+ 
+    /*
+     * Determine if content-type can be displayed as text or not.
+     * 
+     * @param ct content type
+     * @return true if content-type is of type text.
+     */
+    private static boolean isTextType(String ct){
+    	for (int i = 0; i < TEXT_TYPES.length; i++){
+        	if (ct.startsWith(TEXT_TYPES[i])){
+        		return true;
+        	}    		
+    	}
+    	for (int i = 0; i < TEXT_TYPES_OPT.length; i++){
+        	if (ct.startsWith(TEXT_TYPES_OPT[i])){
+        		return true;
+        	}    		
+    	}
+    	return false;
+    }
 	/**
 	 * Sets the successful attribute of the SampleResult object.
 	 * 

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=597899&r1=597898&r2=597899&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Nov 24 09:59:23 2007
@@ -158,6 +158,7 @@
 <li>Fix default encoding for blank encoding</li>
 <li>Fix Https spoofing (port problem) which was broken in 2.3</li>
 <li>Fix HTTP (Java) sampler so http.java.sampler.retries means retries, i.e. does not include initial try</li>
+<li>Fix SampleResult dataType checking to better detect TEXT documents</li>
 </ul>
 
 <h4>Improvements</h4>
@@ -204,6 +205,7 @@
 <li>Add Successes Only logging and display</li>
 <li>The JMeter log file name is formatted as a SimpleDateFormat (applied to the current date) if it contains paired single-quotes,  .e.g. 'jmeter_'yyyyMMddHHmmss'.log'</li>
 <li>Added Collapse All and Expand All Option menu items</li>
+<li>Allow optional definition of extra content-types that are viewable as text</li>
 </ul>
 
 <h4>Non-functional Improvements</h4>



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org