/**
* Creates a new connection to the server.
*/
public static HttpClient createConnection(String hostname, int port, String username, String password, FileSystemOptions fileSystemOptions) throws FileSystemException
{
HttpClient client;
try
{
client = new HttpClient(new MultiThreadedHttpConnectionManager());
final HostConfiguration config = new HostConfiguration();
config.setHost(hostname, port);
if (fileSystemOptions != null)
{
String proxyHost = HttpFileSystemConfigBuilder.getInstance().getProxyHost(fileSystemOptions);
int proxyPort = HttpFileSystemConfigBuilder.getInstance().getProxyPort(fileSystemOptions);
if (proxyHost != null && proxyPort > 0)
{
config.setProxy(proxyHost, proxyPort);
}
}
client.setHostConfiguration(config);
if (username != null)
{
final UsernamePasswordCredentials creds =
new UsernamePasswordCredentials(username, password);
client.getState().setCredentials(null, hostname, creds);
}
client.executeMethod(new HeadMethod());
}
catch (final Exception exc)
{
throw new FileSystemException("vfs.provider.http/connect.error", new Object[]{hostname}, exc);
}