public final class HttpUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
loggerUrl
this logger is for opening connections to remote sites.
|
Constructor and Description |
---|
HttpUtil() |
Modifier and Type | Method and Description |
---|---|
static java.net.URLConnection |
checkRedirect(java.net.URLConnection urlConnection)
check for 301, 302 or 303 redirects, and return a new connection in this case.
|
static void |
consumeStream(java.io.InputStream err)
nice clients consume both the stderr and stdout coming from websites.
|
static void |
copyConnectProperties(java.net.HttpURLConnection urlc,
java.net.HttpURLConnection newConnection)
copy over connection properties like Cookie and Accept-Encoding.
|
static java.util.Map<java.lang.String,java.lang.String> |
getMetadata(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> props)
return the metadata about a URL.
|
protected static final java.util.logging.Logger loggerUrl
public static void consumeStream(java.io.InputStream err) throws java.io.IOException
err
- the input streamjava.io.IOException
public static java.util.Map<java.lang.String,java.lang.String> getMetadata(java.net.URL url, java.util.Map<java.lang.String,java.lang.String> props) throws java.io.IOException
url
- ftp,https, or http URLprops
- if non-null, may be a map containing cookie.java.io.IOException
- when HEAD requests are made.WebProtocol.META_EXIST
,
WebProtocol.HTTP_RESPONSE_CODE
public static void copyConnectProperties(java.net.HttpURLConnection urlc, java.net.HttpURLConnection newConnection)
urlc
- newConnection
- public static java.net.URLConnection checkRedirect(java.net.URLConnection urlConnection) throws java.io.IOException
urlConnection
- if an HttpUrlConnection, check for 301 or 302; return connection otherwise.java.io.IOException