com.google.api.client.http.javanet.DefaultConnectionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of google-http-client Show documentation
Show all versions of google-http-client Show documentation
Google HTTP Client Library for Java. Functionality that works on all supported Java platforms,
including Java 7 (or higher) desktop (SE) and web (EE), Android, and Google App Engine.
The newest version!
package com.google.api.client.http.javanet;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
/**
* Default implementation of {@link ConnectionFactory}, which simply attempts to open the connection
* with an optional {@link Proxy}.
*/
public class DefaultConnectionFactory implements ConnectionFactory {
private final Proxy proxy;
public DefaultConnectionFactory() {
this(null);
}
/**
* @param proxy HTTP proxy or {@code null} to use the proxy settings from
* system properties
*/
public DefaultConnectionFactory(Proxy proxy) {
this.proxy = proxy;
}
@Override
public HttpURLConnection openConnection(URL url) throws IOException {
return (HttpURLConnection) (proxy == null ? url.openConnection() : url.openConnection(proxy));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy