jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1859651 - in /jmeter/trunk/src: core/org/apache/jmeter/samplers/SampleResult.java protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
Date Tue, 21 May 2019 14:24:52 GMT
Author: pmouawad
Date: Tue May 21 14:24:52 2019
New Revision: 1859651

URL: http://svn.apache.org/viewvc?rev=1859651&view=rev
Log:
Fix TODO: Use more complete detection of binary content type

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1859651&r1=1859650&r2=1859651&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Tue May 21 14:24:52
2019
@@ -901,7 +901,7 @@ public class SampleResult implements Ser
      * @param ct content type
      * @return true if content-type is of type binary.
      */
-    private static boolean isBinaryType(String ct){
+    public static boolean isBinaryType(String ct){
         for (String entry : NON_BINARY_TYPES){
             if (ct.startsWith(entry)){
                 return false;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=1859651&r1=1859650&r2=1859651&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java Tue May
21 14:24:52 2019
@@ -97,9 +97,6 @@ public class Proxy extends Thread {
         log.info("Proxy will remove the headers: {}", removeList);
     }
 
-    // Use with SSL connection
-    private OutputStream outStreamClient = null;
-
     /** Socket to client. */
     private Socket clientSocket = null;
 
@@ -177,9 +174,10 @@ public class Proxy extends Thread {
                 throw new JMeterException(); // hack to skip processing
             }
             if (isDebug) {
-                log.debug("{} Initial request: {}", port, new String(ba));
+                log.debug("{} Initial request: {}", port, new String(ba)); // NOSONAR False
positive
             }
-            outStreamClient = clientSocket.getOutputStream();
+            // Use with SSL connection
+            OutputStream outStreamClient = clientSocket.getOutputStream();
 
             if ((request.getMethod().startsWith(HTTPConstants.CONNECT)) && (outStreamClient
!= null)) {
                 log.debug("{} Method CONNECT => SSL", port);
@@ -210,7 +208,7 @@ public class Proxy extends Thread {
                     throw new JMeterException(); // hack to skip processing
                 }
                 if (isDebug) {
-                    log.debug("{} Reparse: {}", port, new String(ba));
+                    log.debug("{} Reparse: {}", port, new String(ba)); // NOSONAR False positive
                 }
                 if (ba.length == 0) {
                     log.warn("{} Empty response to http over SSL. Probably waiting for user
to authorize the certificate for {}",
@@ -596,14 +594,19 @@ public class Proxy extends Thread {
      */
     private void addFormEncodings(SampleResult result, String pageEncoding) {
         FormCharSetFinder finder = new FormCharSetFinder();
-        if (!result.getContentType().startsWith("text/")){ // TODO perhaps make more specific
than this?
+        if (SampleResult.isBinaryType(result.getContentType())) {
+            if (log.isDebugEnabled()) {
+                log.debug("Will not guess encoding of url:{} as it's binary", result.getUrlAsString());
+            }
             return; // no point parsing anything else, e.g. GIF ...
         }
         try {
             finder.addFormActionsAndCharSet(result.getResponseDataAsString(), formEncodings,
pageEncoding);
         }
         catch (HTMLParseException parseException) {
-            log.debug("{} Unable to parse response, could not find any form character set
encodings", port);
+            if (log.isDebugEnabled()) {
+                log.debug("{} Unable to parse response, could not find any form character
set encodings for url:{}", port, result.getUrlAsString());
+            }
         }
     }
 



Mime
View raw message