private RestTemplate createRestTemplate(final StringBuilder buffer) {
		RestTemplate restTemplate = new RestTemplate();

		restTemplate.setErrorHandler(new ResponseErrorHandler() {
			@Override
			public boolean hasError(ClientHttpResponse response) throws IOException {
				HttpStatus status = response.getStatusCode();
				return (status == HttpStatus.BAD_GATEWAY || status == HttpStatus.GATEWAY_TIMEOUT || status == HttpStatus.INTERNAL_SERVER_ERROR);
			}

			@Override
			public void handleError(ClientHttpResponse response) throws IOException {
				outputError(response.getStatusCode(), buffer);
			}
		});

		return restTemplate;
	}
Http commands.

@author Jon Brisbin
@author Ilayaperumal Gopinathan
@author Gunnar Hillert
@author Eric Bottard
@author David Turanski
spring-xd-shell/src/main/java/org/springframework/xd/shell/command/HttpCommands.java