private <T> ClientRequest createClientRequest(String method,
Class<T> responseEntity,
Type responseEntityType,
Object requestEntity) {
ClientRequest request = new ClientRequestImpl();
request.setEntity(requestEntity);
URI requestURI = uriBuilder.build();
request.setURI(requestURI);
request.setMethod(method);
request.getHeaders().putAll(headers);
if (logger.isTraceEnabled()) {
Integer requestEntityInfo =
(requestEntity == null) ? null : System.identityHashCode(requestEntity);
logger.trace(Messages.getMessage("clientIssueRequest", new Object[] {method, //$NON-NLS-1$
requestURI, requestEntityInfo, headers.keySet()}));
}
if (headers.getFirst(HttpHeaders.USER_AGENT) == null) {
request.getHeaders().add(HttpHeaders.USER_AGENT, USER_AGENT);
}
request.getAttributes().putAll(attributes);
request.setAttribute(ProvidersRegistry.class, providersRegistry);
request.setAttribute(WinkConfiguration.class, config);
request.setAttribute(ClientConfig.class, config); // legacy
request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
responseEntityType);
request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
return request;
}