Print request body in PrintingResultHandler in Spring MVC Test
Prior to this commit, the PrintingResultHandler used by the various print() and log() methods in Spring MVC Test printed the response body but not the request body. Since request bodies are sometimes generated programmatically, however, it can be beneficial to have the dynamically generated request body logged as well. This commit therefore prints the request body in PrintingResultHandler by delegating to the recently introduced getContentAsString() method in MockHttpServletRequest. Issue: SPR-14717
This commit is contained in:
@@ -107,6 +107,7 @@ public class PrintingResultHandler implements ResultHandler {
|
||||
this.printer.printValue("Request URI", request.getRequestURI());
|
||||
this.printer.printValue("Parameters", getParamsMultiValueMap(request));
|
||||
this.printer.printValue("Headers", getRequestHeaders(request));
|
||||
this.printer.printValue("Body", request.getContentAsString());
|
||||
}
|
||||
|
||||
protected final HttpHeaders getRequestHeaders(MockHttpServletRequest request) {
|
||||
|
||||
Reference in New Issue
Block a user