class HttpResponseTransformer {

    public WilmaHttpResponse transformResponse(final BrowserMobHttpResponse response) {
        boolean isResponseVolatile = response.isResponseVolatile();
        WilmaHttpResponse result = responseFactory.createNewWilmaHttpResponse(isResponseVolatile);
        if (response.getRawResponse() != null) {
            for (Header header : response.getRawResponse().getAllHeaders()) {
                result.addHeader(header.getName(), header.getValue());
            }
        }

        for (Header header : response.getRequestHeaders()) {
            result.addRequestHeader(header.getName(), header.getValue());
        }

        result.setRequestLine(response.getMethod().getRequestLine().toString());
        result.setProxyRequestLine(response.getProxyRequestURI().toString());
        String body = response.getBody();
        int status = response.getStatus();
        result.setBody(body);
        result.setContentType(response.getContentType());
        result.setStatusCode(status);

        //set Wilma Message Id
        String instancePrefix = prepareInstancePrefix();
        result.setWilmaMessageId(instancePrefix + response.getEntry().getWilmaEntryId());

        //set remote addr
        String ipAddress = response.getEntry().getServerIPAddress();
        result.setRemoteAddr(ipAddress);

        return result;
    }

}