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()));
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$
Integer.valueOf(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$
// Concatenate query post if exists
String queryPost = sampleResult.getQueryString();
if (queryPost != null && queryPost.length() > 0) {
if (queryGet.length() > 0) {
queryGet += PARAM_CONCATENATE;
}
queryGet += queryPost;
}
queryGet = RequestViewHTTP.decodeQuery(queryGet);
if (queryGet != null) {
Set<Entry<String, String>> keys = RequestViewHTTP.getQueryMap(queryGet).entrySet();
for (Entry<String, String> entry : keys) {
paramsModel.addRow(new RowResult(entry.getKey(),entry.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()));
}
// Parsed request headers
LinkedHashMap<String, String> lhm = JMeterUtils.parseHeaders(sampleResult.getRequestHeaders());
for (Iterator<Map.Entry<String, String>> iterator = lhm.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, String> entry = iterator.next();
headersModel.addRow(new RowResult(entry.getKey(), entry.getValue()));
}
} 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$
}
}