private RequestWrapper wrapRequest( final HttpRequest request) throws ProtocolException { if (request instanceof HttpEntityEnclosingRequest) { return new EntityEnclosingRequestWrapper( (HttpEntityEnclosingRequest) request); } else { return new RequestWrapper( request); } }