Class ConnectionFactory
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.http.ConnectionFactory
-
public class ConnectionFactory extends java.lang.ObjectFactory for opening connections to URLs.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateConnectionFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static CloseableHttpConnectioncreateHttpConnection(java.net.HttpURLConnection httpConnection, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties)Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.private static CloseableHttpConnectioncreateHttpConnection(java.net.HttpURLConnection httpConnection, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout)Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.static CloseableConnectionopenConnection(java.net.URL url)Opens a connection to an URL.static CloseableConnectionopenConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties)Opens a connection to a URL.static CloseableConnectionopenConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout)Opens a connection to a URL.static CloseableHttpConnectionopenHttpConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties)Opens a connection to a URL.static CloseableHttpConnectionopenHttpConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout)Opens a connection to a URL.
-
-
-
Method Detail
-
openConnection
public static CloseableConnection openConnection(java.net.URL url) throws java.io.IOException
Opens a connection to an URL.- Parameters:
url- the url to which to open a connection.- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
openConnection
public static CloseableConnection openConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties) throws java.io.IOException
Opens a connection to a URL.If the URL has HTTP or HTTPS as its protocol than
HttpURLConnectionis opened and therequestMethodandrequestPropertiesare set onto the connection. Otherwise therequestMethodandrequestPropertiesare ignored.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
openConnection
public static CloseableConnection openConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws java.io.IOException
Opens a connection to a URL.If the URL has HTTP or HTTPS as its protocol than
HttpURLConnectionis opened and therequestMethodandrequestPropertiesare set onto the connection. Otherwise therequestMethodandrequestPropertiesare ignored.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
openHttpConnection
public static CloseableHttpConnection openHttpConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties) throws java.io.IOException
Opens a connection to a URL.If the URL has not HTTP or HTTPS as its protocol a
IllegalArgumentExceptionis thrown. Otherwise therequestMethodandrequestPropertiesare set onto the connection.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
openHttpConnection
public static CloseableHttpConnection openHttpConnection(java.net.URL url, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws java.io.IOException
Opens a connection to a URL.If the URL has not HTTP or HTTPS as its protocol a
IllegalArgumentExceptionis thrown. Otherwise therequestMethodandrequestPropertiesare set onto the connection.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
createHttpConnection
private static CloseableHttpConnection createHttpConnection(java.net.HttpURLConnection httpConnection, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties) throws java.io.IOException
Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.- Parameters:
httpConnection- the connection to wrap.requestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
createHttpConnection
private static CloseableHttpConnection createHttpConnection(java.net.HttpURLConnection httpConnection, HttpMethod requestMethod, java.util.Map<java.lang.String,java.lang.String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws java.io.IOException
Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.- Parameters:
httpConnection- the connection to wrap.requestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
java.io.IOException- if an I/O exception occurs.
-
-