Package com.cedarsoftware.util
Class UrlUtilities
java.lang.Object
com.cedarsoftware.util.UrlUtilities
Deprecated.
Useful utilities for working with UrlConnections and IO.
Anyone using the deprecated api calls for proxying to urls should update to use the new suggested calls.
To let the jvm proxy for you automatically, use the following -D parameters:
http.proxyHost
http.proxyPort (default: 80)
http.nonProxyHosts (should always include localhost)
https.proxyHost
https.proxyPort
Example: -Dhttp.proxyHost=proxy.example.org -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.example.org -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=*.foo.com|localhost|*.td.afg
- Author:
- Ken Partlow, John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Deprecated.static final String
Deprecated.static final SafeSimpleDateFormat
Deprecated.static final char
Deprecated.static final String
Deprecated.static final TrustManager[]
Deprecated.static final HostnameVerifier
Deprecated.protected static SSLSocketFactory
Deprecated.static final char
Deprecated.static final String
Deprecated.static final ThreadLocal<String>
Deprecated.static final String
Deprecated.static final String
Deprecated.static final ThreadLocal<String>
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Deprecated.static void
Deprecated.static void
Deprecated.static URL
getActualUrl
(String url) Deprecated.static URLConnection
getConnection
(String url, boolean input, boolean output, boolean cache) Deprecated.static URLConnection
getConnection
(URL url, boolean input, boolean output, boolean cache) Deprecated.static URLConnection
getConnection
(URL url, Map inCookies, boolean input, boolean output, boolean cache, boolean allowAllCerts) Deprecated.Gets a connection from a url.static byte[]
getContentFromUrl
(String url) Deprecated.Get content from the passed in URL.static byte[]
getContentFromUrl
(String url, Map inCookies, Map outCookies) Deprecated.Get content from the passed in URL.static byte[]
getContentFromUrl
(String url, Map inCookies, Map outCookies, boolean allowAllCerts) Deprecated.static byte[]
getContentFromUrl
(URL url, boolean allowAllCerts) Deprecated.Get content from the passed in URL.static byte[]
getContentFromUrl
(URL url, Map inCookies, Map outCookies, boolean allowAllCerts) Deprecated.Get content from the passed in URL.static String
Deprecated.Get content from the passed in URL.static String
getContentFromUrlAsString
(String url, Map inCookies, Map outCookies, boolean trustAllCerts) Deprecated.Get content from the passed in URL.static String
getContentFromUrlAsString
(URL url, boolean allowAllCerts) Deprecated.Get content from the passed in URL.static String
getContentFromUrlAsString
(URL url, Map inCookies, Map outCookies, boolean trustAllCerts) Deprecated.Get content from the passed in URL.static String
Deprecated.static void
getCookies
(URLConnection conn, Map store) Deprecated.Retrieves and stores cookies returned by the host on the other side of the open java.net.URLConnection.static String
Deprecated.static String
Deprecated.static void
Deprecated.static void
setCookies
(URLConnection conn, Map store) Deprecated.Prior to opening a URLConnection, calling this method will set all unexpired cookies that match the path or subpaths for thi underlying URLstatic void
setReferrer
(String referer) Deprecated.static void
setUserAgent
(String agent) Deprecated.
-
Field Details
-
userAgent
Deprecated. -
referrer
Deprecated. -
SET_COOKIE
Deprecated.- See Also:
-
SET_COOKIE_SEPARATOR
Deprecated.- See Also:
-
COOKIE
Deprecated.- See Also:
-
COOKIE_VALUE_DELIMITER
Deprecated.- See Also:
-
PATH
Deprecated.- See Also:
-
EXPIRES
Deprecated.- See Also:
-
DATE_FORMAT
Deprecated. -
NAME_VALUE_SEPARATOR
public static final char NAME_VALUE_SEPARATORDeprecated.- See Also:
-
DOT
public static final char DOTDeprecated.- See Also:
-
NAIVE_TRUST_MANAGER
Deprecated. -
NAIVE_VERIFIER
Deprecated. -
naiveSSLSocketFactory
Deprecated.
-
-
Method Details
-
clearGlobalUserAgent
public static void clearGlobalUserAgent()Deprecated. -
clearGlobalReferrer
public static void clearGlobalReferrer()Deprecated. -
setReferrer
Deprecated. -
getReferrer
Deprecated. -
setUserAgent
Deprecated. -
getUserAgent
Deprecated. -
readErrorResponse
Deprecated. -
disconnect
Deprecated. -
getCookies
Deprecated.Retrieves and stores cookies returned by the host on the other side of the open java.net.URLConnection.The connection MUST have been opened using the connect() method or a IOException will be thrown.
- Parameters:
conn
- a java.net.URLConnection - must be open, or IOException will be thrown
-
setCookies
Deprecated.Prior to opening a URLConnection, calling this method will set all unexpired cookies that match the path or subpaths for thi underlying URLThe connection MUST NOT have been opened method or an IOException will be thrown.
- Parameters:
conn
- a java.net.URLConnection - must NOT be open, or IOException will be thrown- Throws:
IOException
- Thrown if conn has already been opened.
-
getCookieDomainFromHost
Deprecated. -
getContentFromUrlAsString
Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a String.- Parameters:
url
- URL to hit- Returns:
- UTF-8 String read from URL or null in the case of error.
-
getContentFromUrlAsString
Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a String.- Parameters:
url
- URL to hitallowAllCerts
- true to not verify certificates- Returns:
- UTF-8 String read from URL or null in the case of error.
-
getContentFromUrlAsString
public static String getContentFromUrlAsString(String url, Map inCookies, Map outCookies, boolean trustAllCerts) Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a String.- Parameters:
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.- Returns:
- String of content fetched from URL.
-
getContentFromUrlAsString
public static String getContentFromUrlAsString(URL url, Map inCookies, Map outCookies, boolean trustAllCerts) Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a String.- Parameters:
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.- Returns:
- String of content fetched from URL.
-
getContentFromUrl
Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a byte[].- Parameters:
url
- URL to hit- Returns:
- byte[] read from URL or null in the case of error.
-
getContentFromUrl
Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a byte[].- Parameters:
url
- URL to hit- Returns:
- byte[] read from URL or null in the case of error.
-
getContentFromUrl
public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, boolean allowAllCerts) Deprecated. -
getContentFromUrl
public static byte[] getContentFromUrl(URL url, Map inCookies, Map outCookies, boolean allowAllCerts) Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a byte[].- Parameters:
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?- Returns:
- byte[] of content fetched from URL.
-
getContentFromUrl
Deprecated.Get content from the passed in URL. This code will open a connection to the passed in server, fetch the requested content, and return it as a byte[].- Parameters:
url
- URL to hitinCookies
- Map of session cookies (or null if not needed)outCookies
- Map of session cookies (or null if not needed)- Returns:
- byte[] of content fetched from URL.
-
getConnection
public static URLConnection getConnection(String url, boolean input, boolean output, boolean cache) throws IOException Deprecated.- Parameters:
input
- boolean indicating whether this connection will be used for inputoutput
- boolean indicating whether this connection will be used for outputcache
- boolean allow caching (be careful setting this to true for non-static retrievals).- Returns:
- URLConnection established URL connection.
- Throws:
IOException
-
getConnection
public static URLConnection getConnection(URL url, boolean input, boolean output, boolean cache) throws IOException Deprecated.- Parameters:
input
- boolean indicating whether this connection will be used for inputoutput
- boolean indicating whether this connection will be used for outputcache
- boolean allow caching (be careful setting this to true for non-static retrievals).- Returns:
- URLConnection established URL connection.
- Throws:
IOException
-
getConnection
public static URLConnection getConnection(URL url, Map inCookies, boolean input, boolean output, boolean cache, boolean allowAllCerts) throws IOException Deprecated.Gets a connection from a url. All getConnection calls should go through this code.- Parameters:
inCookies
- Supply cookie Map (received from prior setCookies calls from server)input
- boolean indicating whether this connection will be used for inputoutput
- boolean indicating whether this connection will be used for outputcache
- boolean allow caching (be careful setting this to true for non-static retrievals).- Returns:
- URLConnection established URL connection.
- Throws:
IOException
-
getActualUrl
Deprecated.- Throws:
MalformedURLException
-