private Task preProcess(HttpRequest request) {
final RequestLine rl = request.getRequestLine();
final String taskName = String.format("%S %s %S", rl.getMethod(), rl.getUri(), request.getProtocolVersion());
final Task task = taskManagerService.createSubTask(taskName, TASK_GROUP_CLIENT);
task.updateMessage("preparing request");
task.updateDetailMessage("method", rl.getMethod());
task.updateDetailMessage("url", rl.getUri());
// TODO: some more detail messages?
if (request instanceof HttpEntityEnclosingRequest) {
// To report upload progress, the entity is wrapped in a MonitoredHttpEntity.
final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) request;
entityRequest.setEntity(new MonitoredHttpEntity(entityRequest.getEntity(), task, bytesSent));
}
task.updateMessage("sending request");
return task;
}