public BaseHttpResponse(ExtendedHttpMethod httpMethod, AbstractHttpRequestInterface<?> httpRequest,
PropertyExpansionContext context) {
this.httpRequest = new WeakReference<AbstractHttpRequestInterface<?>>(httpRequest);
this.timeTaken = httpMethod.getTimeTaken();
SoapUIMetrics metrics = httpMethod.getMetrics();
method = httpMethod.getMethod();
version = httpMethod.getProtocolVersion().toString();
try {
this.url = httpMethod.getURL();
} catch (Exception e1) {
SoapUI.logError(e1);
}
if (!httpMethod.isFailed()) {
Settings settings = httpRequest.getSettings();
try {
rawResponseBody = httpMethod.getResponseBody();
} catch (IOException e) {
e.printStackTrace();
}
if (settings.getBoolean(HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN)) {
timeTaken += httpMethod.getResponseReadTime();
}
// metrics.getReadTimer().add( httpMethod.getResponseReadTimeNanos() );
// metrics.getTotalTimer().add( httpMethod.getResponseReadTimeNanos() );
metrics.getReadTimer().add(httpMethod.getResponseReadTime());
metrics.getTotalTimer().add(httpMethod.getResponseReadTime());
try {
this.timestamp = System.currentTimeMillis();
this.contentType = httpMethod.getResponseContentType();
this.statusCode = extractStatusCode(httpMethod);
this.sslInfo = httpMethod.getSSLInfo();
this.url = httpMethod.getURL();
metrics.setTimestamp(getTimestamp());
metrics.setHttpStatus(getStatusCode());
} catch (Exception e) {
e.printStackTrace();
}
}
if (httpRequest instanceof TestRequest) {
TestCase tc = ((TestRequest) httpRequest).getTestStep().getTestCase();
if (tc instanceof WsdlTestCase && ((WsdlTestCase) tc).isForLoadTest()) {
initHeadersForLoadTest(httpMethod);
return;
}
}
initHeaders(httpMethod);
AbstractHttpRequestInterface<?> requestInterface = this.httpRequest.get();
if (requestInterface instanceof HttpRequest) {
boolean downloadIncludedResources = ((HttpRequest) requestInterface).getDownloadIncludedResources();
if (downloadIncludedResources) {
long beforeNanos = System.nanoTime();
addIncludedContentsAsAttachments();
long afterNanos = System.nanoTime();
timeTaken += ((afterNanos - beforeNanos) / 1000000);
metrics.getTotalTimer().add(afterNanos - beforeNanos);
context.setProperty(HTMLPageSourceDownloader.MISSING_RESOURCES_LIST, downloader.getMissingResourcesList());
}
}
}