public void setSamplerResult()

in src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java [173:254]


    public void setSamplerResult(Object objectResult) {

        this.searchTextExtension.resetTextToFind();
        if (objectResult instanceof HTTPSampleResult) {
            HTTPSampleResult sampleResult = (HTTPSampleResult) objectResult;

            // Display with same order HTTP protocol
            requestModel.addRow(new RowResult(
                    JMeterUtils.getResString("view_results_table_request_http_method"), //$NON-NLS-1$
                    sampleResult.getHTTPMethod()));

            // Parsed request headers
            LinkedHashMap<String, String> lhm = JMeterUtils.parseHeaders(sampleResult.getRequestHeaders());
            for (Map.Entry<String, String> entry : lhm.entrySet()) {
                headersModel.addRow(new RowResult(entry.getKey(), entry.getValue()));
            }

            URL hUrl = sampleResult.getURL();
            if (hUrl != null){ // can be null - e.g. if URL was invalid
                requestModel.addRow(new RowResult(JMeterUtils
                        .getResString("view_results_table_request_http_protocol"), //$NON-NLS-1$
                        hUrl.getProtocol()));
                requestModel.addRow(new RowResult(
                        JMeterUtils.getResString("view_results_table_request_http_host"), //$NON-NLS-1$
                        hUrl.getHost()));
                int port = hUrl.getPort() == -1 ? hUrl.getDefaultPort() : hUrl.getPort();
                requestModel.addRow(new RowResult(
                        JMeterUtils.getResString("view_results_table_request_http_port"), //$NON-NLS-1$
                        port));
                requestModel.addRow(new RowResult(
                        JMeterUtils.getResString("view_results_table_request_http_path"), //$NON-NLS-1$
                        hUrl.getPath()));

                String queryGet = hUrl.getQuery() == null ? "" : hUrl.getQuery(); //$NON-NLS-1$
                boolean isMultipart = isMultipart(lhm);

                // Concatenate query post if exists
                String queryPost = sampleResult.getQueryString();
                if (!isMultipart && StringUtils.isNotBlank(queryPost)) {
                    if (queryGet.length() > 0) {
                        queryGet += PARAM_CONCATENATE;
                    }
                    queryGet += queryPost;
                }

                if (StringUtils.isNotBlank(queryGet)) {
                    Set<Map.Entry<String, String[]>> keys = RequestViewHTTP.getQueryMap(queryGet).entrySet();
                    for (Map.Entry<String, String[]> entry : keys) {
                        for (String value : entry.getValue()) {
                            paramsModel.addRow(new RowResult(entry.getKey(), value));
                        }
                    }
                }

                if(isMultipart && StringUtils.isNotBlank(queryPost)) {
                    String contentType = lhm.get(HTTPConstants.HEADER_CONTENT_TYPE);
                    String boundaryString = extractBoundary(contentType);
                    MultipartUrlConfig urlconfig = new MultipartUrlConfig(boundaryString);
                    urlconfig.parseArguments(queryPost);

                    for(JMeterProperty prop : urlconfig.getArguments()) {
                        Argument arg = (Argument) prop.getObjectValue();
                        paramsModel.addRow(new RowResult(arg.getName(), arg.getValue()));
                    }
                }
            }

            // Display cookie in headers table (same location on http protocol)
            String cookie = sampleResult.getCookies();
            if (cookie != null && cookie.length() > 0) {
                headersModel.addRow(new RowResult(
                        JMeterUtils.getParsedLabel("view_results_table_request_http_cookie"), //$NON-NLS-1$
                        sampleResult.getCookies()));
            }

        }
        else {
            // add a message when no http sample
            requestModel.addRow(new RowResult("", //$NON-NLS-1$
                    JMeterUtils.getResString("view_results_table_request_http_nohttp"))); //$NON-NLS-1$
        }
    }