public final class UrlUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COOKIE |
static String |
COOKIE_VALUE_DELIMITER |
static SafeSimpleDateFormat |
DATE_FORMAT |
static char |
DOT |
static String |
EXPIRES |
static TrustManager[] |
NAIVE_TRUST_MANAGER |
static HostnameVerifier |
NAIVE_VERIFIER |
static SSLSocketFactory |
naiveSSLSocketFactory |
static char |
NAME_VALUE_SEPARATOR |
static String |
PATH |
static String |
SET_COOKIE |
static String |
SET_COOKIE_SEPARATOR |
Modifier and Type | Method and Description |
---|---|
static void |
disconnect(HttpURLConnection c) |
static URL |
getActualUrl(String url) |
static URLConnection |
getConnection(String url,
boolean input,
boolean output,
boolean cache) |
static URLConnection |
getConnection(URL url,
boolean input,
boolean output,
boolean cache) |
static URLConnection |
getConnection(URL url,
Map inCookies,
boolean input,
boolean output,
boolean cache,
boolean allowAllCerts)
Gets a connection from a url.
|
static URLConnection |
getConnection(URL url,
Map inCookies,
boolean input,
boolean output,
boolean cache,
Proxy proxy,
boolean allowAllCerts)
Deprecated.
As of release 1.13.0, replaced by
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean) |
static URLConnection |
getConnection(URL url,
Map inCookies,
boolean input,
boolean output,
boolean cache,
Proxy proxy,
SSLSocketFactory factory,
HostnameVerifier verifier)
Deprecated.
As of release 1.13.0, replaced by
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean) |
static URLConnection |
getConnection(URL url,
String server,
int port,
Map inCookies,
boolean input,
boolean output,
boolean cache,
boolean allowAllCerts)
Deprecated.
As of release 1.13.0, replaced by
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean) |
static byte[] |
getContentFromUrl(String url)
Get content from the passed in URL.
|
static byte[] |
getContentFromUrl(String url,
Map inCookies,
Map outCookies)
Get content from the passed in URL.
|
static byte[] |
getContentFromUrl(String url,
Map inCookies,
Map outCookies,
boolean allowAllCerts) |
static byte[] |
getContentFromUrl(String url,
Map inCookies,
Map outCookies,
Proxy proxy,
boolean allowAllCerts)
Deprecated.
As of release 1.13.0, replaced by
getConnection(String, boolean, boolean, boolean) |
static byte[] |
getContentFromUrl(String url,
Map inCookies,
Map outCookies,
Proxy proxy,
SSLSocketFactory factory,
HostnameVerifier verifier)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String) |
static byte[] |
getContentFromUrl(String url,
Proxy proxy)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String) |
static byte[] |
getContentFromUrl(String url,
Proxy proxy,
SSLSocketFactory factory,
HostnameVerifier verifier)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String) |
static byte[] |
getContentFromUrl(String url,
String proxyServer,
int port,
Map inCookies,
Map outCookies,
boolean allowAllCerts)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String, java.util.Map, java.util.Map, boolean) |
static byte[] |
getContentFromUrl(URL url,
boolean allowAllCerts)
Get content from the passed in URL.
|
static byte[] |
getContentFromUrl(URL url,
Map inCookies,
Map outCookies,
boolean allowAllCerts)
Get content from the passed in URL.
|
static byte[] |
getContentFromUrl(URL url,
Map inCookies,
Map outCookies,
Proxy proxy,
boolean allowAllCerts)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String, java.util.Map, java.util.Map, boolean) |
static String |
getContentFromUrlAsString(String url)
Get content from the passed in URL.
|
static String |
getContentFromUrlAsString(String url,
Map inCookies,
Map outCookies,
boolean trustAllCerts)
Get content from the passed in URL.
|
static String |
getContentFromUrlAsString(String url,
Proxy proxy)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrl(String) |
static String |
getContentFromUrlAsString(String url,
String proxyServer,
int port,
Map inCookies,
Map outCookies,
boolean ignoreSec)
Deprecated.
As of release 1.13.0, replaced by
getContentFromUrlAsString(String, java.util.Map, java.util.Map, boolean) |
static String |
getContentFromUrlAsString(URL url,
boolean allowAllCerts)
Get content from the passed in URL.
|
static String |
getContentFromUrlAsString(URL url,
Map inCookies,
Map outCookies,
boolean trustAllCerts)
Get content from the passed in URL.
|
static String |
getCookieDomainFromHost(String host) |
static void |
getCookies(URLConnection conn,
Map store)
Retrieves and stores cookies returned by the host on the other side of
the open java.net.URLConnection.
|
static String |
getHostName()
Deprecated.
As of release 1.13.0, replaced by
InetAddressUtilities.getHostName() |
static String |
getUserAgent() |
static void |
readErrorResponse(URLConnection c) |
static void |
setCookies(URLConnection conn,
Map store)
Prior to opening a URLConnection, calling this method will set all
unexpired cookies that match the path or subpaths for thi underlying URL
The connection MUST NOT have been opened
method or an IOException will be thrown.
|
static void |
setReferrer(String referrer) |
static void |
setUserAgent(String userAgent) |
public static final String SET_COOKIE
public static final String COOKIE_VALUE_DELIMITER
public static final String PATH
public static final String EXPIRES
public static final SafeSimpleDateFormat DATE_FORMAT
public static final String SET_COOKIE_SEPARATOR
public static final String COOKIE
public static final char NAME_VALUE_SEPARATOR
public static final char DOT
public static final TrustManager[] NAIVE_TRUST_MANAGER
public static final HostnameVerifier NAIVE_VERIFIER
public static SSLSocketFactory naiveSSLSocketFactory
public static void setReferrer(String referrer)
public static void setUserAgent(String userAgent)
public static String getUserAgent()
public static void readErrorResponse(URLConnection c)
public static void disconnect(HttpURLConnection c)
public static void getCookies(URLConnection conn, Map store)
conn
- a java.net.URLConnection - must be open, or IOException will
be thrownpublic static void setCookies(URLConnection conn, Map store) throws IOException
conn
- a java.net.URLConnection - must NOT be open, or IOException will be thrownIOException
- Thrown if conn has already been opened.public static String getContentFromUrlAsString(String url)
url
- URL to hitpublic static String getContentFromUrlAsString(URL url, boolean allowAllCerts)
url
- URL to hitallowAllCerts
- true to not verify certificatespublic static String getContentFromUrlAsString(String url, Map inCookies, Map outCookies, boolean trustAllCerts)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)trustAllCerts
- if true, SSL connection will always be trusted.public static String getContentFromUrlAsString(URL url, Map inCookies, Map outCookies, boolean trustAllCerts)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)trustAllCerts
- if true, SSL connection will always be trusted.public static byte[] getContentFromUrl(String url)
url
- URL to hitpublic static byte[] getContentFromUrl(URL url, boolean allowAllCerts)
url
- URL to hitpublic static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, boolean allowAllCerts)
public static byte[] getContentFromUrl(URL url, Map inCookies, Map outCookies, boolean allowAllCerts)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)allowAllCerts
- override certificate validation?public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)public static URLConnection getConnection(String url, boolean input, boolean output, boolean cache) throws IOException
url
- input
- output
- cache
- IOException
public static URLConnection getConnection(URL url, boolean input, boolean output, boolean cache) throws IOException
url
- input
- output
- cache
- IOException
public static URLConnection getConnection(URL url, Map inCookies, boolean input, boolean output, boolean cache, boolean allowAllCerts) throws IOException
url
- inCookies
- input
- output
- cache
- IOException
public static URL getActualUrl(String url) throws MalformedURLException
MalformedURLException
@Deprecated public static String getHostName()
InetAddressUtilities.getHostName()
@Deprecated public static URLConnection getConnection(URL url, Map inCookies, boolean input, boolean output, boolean cache, Proxy proxy, boolean allowAllCerts) throws IOException
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean)
url
- inCookies
- input
- output
- cache
- proxy
- IOException
@Deprecated public static URLConnection getConnection(URL url, String server, int port, Map inCookies, boolean input, boolean output, boolean cache, boolean allowAllCerts) throws IOException
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean)
url
- server
- port
- inCookies
- input
- output
- cache
- allowAllCerts
- IOException
@Deprecated public static URLConnection getConnection(URL url, Map inCookies, boolean input, boolean output, boolean cache, Proxy proxy, SSLSocketFactory factory, HostnameVerifier verifier) throws IOException
getConnection(java.net.URL, java.util.Map, boolean, boolean, boolean, boolean)
url
- inCookies
- input
- output
- cache
- proxy
- factory
- verifier
- IOException
@Deprecated public static byte[] getContentFromUrl(String url, Proxy proxy)
getContentFromUrl(String)
url
- URL to hitproxy
- proxy to use to create connection@Deprecated public static byte[] getContentFromUrl(String url, Proxy proxy, SSLSocketFactory factory, HostnameVerifier verifier)
getContentFromUrl(String)
url
- URL to hitproxy
- Proxy server to create connection (or null if not needed)factory
- custom SSLSocket factory (or null if not needed)verifier
- custom Hostnameverifier (or null if not needed)@Deprecated public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, Proxy proxy, SSLSocketFactory factory, HostnameVerifier verifier)
getContentFromUrl(String)
url
- URL to hitinCookies
- outCookies
- proxy
- Proxy server to create connection (or null if not needed)factory
- custom SSLSocket factory (or null if not needed)verifier
- custom Hostnameverifier (or null if not needed)@Deprecated public static String getContentFromUrlAsString(String url, Proxy proxy)
getContentFromUrl(String)
url
- URL to hitproxy
- proxy to use to create connection@Deprecated public static byte[] getContentFromUrl(URL url, Map inCookies, Map outCookies, Proxy proxy, boolean allowAllCerts)
getContentFromUrl(String, java.util.Map, java.util.Map, boolean)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)proxy
- Proxy server to create connection (or null if not needed)@Deprecated public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, Proxy proxy, boolean allowAllCerts)
getConnection(String, boolean, boolean, boolean)
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)proxy
- Proxy server to create connection (or null if not needed)@Deprecated public static byte[] getContentFromUrl(String url, String proxyServer, int port, Map inCookies, Map outCookies, boolean allowAllCerts)
getContentFromUrl(String, java.util.Map, java.util.Map, boolean)
url
- URL to hitproxyServer
- String named of proxy serverport
- port to access proxy serverinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)allowAllCerts
- if true, SSL connection will always be trusted.@Deprecated public static String getContentFromUrlAsString(String url, String proxyServer, int port, Map inCookies, Map outCookies, boolean ignoreSec)
getContentFromUrlAsString(String, java.util.Map, java.util.Map, boolean)
url
- URL to hitproxyServer
- String named of proxy serverport
- port to access proxy serverinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)ignoreSec
- if true, SSL connection will always be trusted.Copyright © 2015. All rights reserved.