if (target == null) {
throw new IllegalStateException("Target host may be null");
}
final InetAddress local = ConnRouteParams.getLocalAddress(request.getParams());
final HttpHost proxy = ConnRouteParams.getDefaultProxy(request.getParams());
AsyncScheme scheme;
try {
final AsyncSchemeRegistry registry = getSchemeRegistry(context);
scheme = registry.getScheme(target);
} catch (final IllegalStateException ex) {
throw new HttpException(ex.getMessage());
}
final LayeringStrategy layeringStrategy = scheme.getLayeringStrategy();
final boolean secure = layeringStrategy != null && layeringStrategy.isSecure();
if (proxy == null) {
route = new HttpRoute(target, local, secure);
} else {
route = new HttpRoute(target, local, proxy, secure);