View | Details | Raw Unified | Return to bug 64653
Collapse All | Expand All

(-)a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/Proxy.java (-1 / +20 lines)
Lines 32-37 import java.security.GeneralSecurityException; Link Here
32
import java.security.KeyStore;
32
import java.security.KeyStore;
33
import java.security.KeyStoreException;
33
import java.security.KeyStoreException;
34
import java.util.ArrayList;
34
import java.util.ArrayList;
35
import java.util.Arrays;
35
import java.util.HashMap;
36
import java.util.HashMap;
36
import java.util.List;
37
import java.util.List;
37
import java.util.Map;
38
import java.util.Map;
Lines 63-68 import org.slf4j.LoggerFactory; Link Here
63
 * JMeter test plan.
64
 * JMeter test plan.
64
 */
65
 */
65
public class Proxy extends Thread {
66
public class Proxy extends Thread {
67
    // Mime-types of resources, that are not HTML and not binary that should be skipped on form parsing in JSoup
68
    private static final List<String> NOT_HTML_TEXT_TYPES = Arrays.asList("application/javascript", "application/json", "text/javascript");
69
66
    private static final Logger log = LoggerFactory.getLogger(Proxy.class);
70
    private static final Logger log = LoggerFactory.getLogger(Proxy.class);
67
71
68
    private static final byte[] CRLF_BYTES = { 0x0d, 0x0a };
72
    private static final byte[] CRLF_BYTES = { 0x0d, 0x0a };
Lines 595-604 public class Proxy extends Thread { Link Here
595
        FormCharSetFinder finder = new FormCharSetFinder();
599
        FormCharSetFinder finder = new FormCharSetFinder();
596
        if (SampleResult.isBinaryType(result.getContentType())) {
600
        if (SampleResult.isBinaryType(result.getContentType())) {
597
            if (log.isDebugEnabled()) {
601
            if (log.isDebugEnabled()) {
598
                log.debug("Will not guess encoding of url:{} as it's binary", result.getUrlAsString());
602
                log.debug("Will not guess encoding of URL: {} as it's binary", result.getUrlAsString());
599
            }
603
            }
600
            return; // no point parsing anything else, e.g. GIF ...
604
            return; // no point parsing anything else, e.g. GIF ...
601
        }
605
        }
606
        if (isNotHtmlType(result.getContentType())) {
607
            if (log.isDebugEnabled()) {
608
                log.debug("Will not guess encoding of URL: {} as it's not HTML", result.getUrlAsString());
609
            }
610
            return; // None HTML types have been crashing JSoup parser, so return here early
611
        }
602
        try {
612
        try {
603
            finder.addFormActionsAndCharSet(result.getResponseDataAsString(), formEncodings, pageEncoding);
613
            finder.addFormActionsAndCharSet(result.getResponseDataAsString(), formEncodings, pageEncoding);
604
        }
614
        }
Lines 609-614 public class Proxy extends Thread { Link Here
609
        }
619
        }
610
    }
620
    }
611
621
622
    private boolean isNotHtmlType(String contentType) {
623
        for (String mimeType: NOT_HTML_TEXT_TYPES) {
624
            if (contentType.startsWith(mimeType)) {
625
                return true;
626
            }
627
        }
628
        return false;
629
    }
630
612
    private String getUrlWithoutQuery(URL url) {
631
    private String getUrlWithoutQuery(URL url) {
613
        String fullUrl = url.toString();
632
        String fullUrl = url.toString();
614
        String urlWithoutQuery = fullUrl;
633
        String urlWithoutQuery = fullUrl;

Return to bug 64653