How to log request & response

It would be great to see the complete request & report in a report!

I am thinking about a new keyword doing things like:

'Send a REST request and returns its response ’
RequestObject request = findTestObject(‘REST_POST_token.oauth2’)
def response = WS.sendRequest(request)

keyword #1 - comment request:

String requestHeader = ‘’
Iterator listIterator = request.getHttpHeaderProperties().listIterator()
while (listIterator.hasNext()) {
TestObjectProperty p = (TestObjectProperty)listIterator.next()
requestHeader = requestHeader + p.getName() + ‘=’ + p.getValue() + ‘\n’
}
WebUI.comment(’\nrequest:\n’ + request.restUrl +
‘\n\nrequest header:\n’ + requestHeader +
‘\nrequest data:\n’ + request.httpBody)

keyword #2 - comment response:

String responseHeader = ‘’
HashMap mapResponse = response.getHeaderFields()
Iterator itResponseHeaderKeys = mapResponse.entrySet().iterator();
while (itResponseHeaderKeys.hasNext()) {
responseHeader = responseHeader + itResponseHeaderKeys.next() + ‘\n’
}
WebUI.comment(’\nresponse header:\n’ + responseHeader +
‘\nresponse data:\n’ + response.getResponseText())

Knud,

Did you mean we should have them implemented as built-in keywords?