public class HttpURLConnection extends HttpURLConnection
| Modifier and Type | Field and Description |
|---|---|
protected static int |
defaultConnectTimeout |
protected boolean |
ignoreProxy |
protected boolean |
ignoreSystemNonProxyHosts |
protected IOException |
rememberedException |
chunkLength, fixedContentLength, fixedContentLengthLong, HTTP_ACCEPTED, HTTP_BAD_GATEWAY, HTTP_BAD_METHOD, HTTP_BAD_REQUEST, HTTP_CLIENT_TIMEOUT, HTTP_CONFLICT, HTTP_CREATED, HTTP_ENTITY_TOO_LARGE, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_INTERNAL_ERROR, HTTP_LENGTH_REQUIRED, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_MULT_CHOICE, HTTP_NO_CONTENT, HTTP_NOT_ACCEPTABLE, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_PARTIAL, HTTP_PAYMENT_REQUIRED, HTTP_PRECON_FAILED, HTTP_PROXY_AUTH, HTTP_REQ_TOO_LONG, HTTP_RESET, HTTP_SEE_OTHER, HTTP_SERVER_ERROR, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, responseCode, responseMessageallowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches| Modifier and Type | Method and Description |
|---|---|
void |
addRequestProperty(String key,
String value)
Adds a general request property specified by a key-value pair.
|
void |
connect() |
void |
disconnect()
Disconnect from the server.
|
protected void |
doSetRequests() |
protected boolean |
followRedirect() |
static String |
getAuthInfo(String host,
int port,
String header) |
int |
getConnectTimeout() |
InputStream |
getErrorStream() |
String |
getHeaderField(int n)
Gets a header field by index.
|
String |
getHeaderField(String name)
Gets a header field by name.
|
String |
getHeaderFieldKey(int n)
Gets a header field by index.
|
Map |
getHeaderFields()
Gets all header fields.
|
protected HttpClient |
getHttpClient() |
InputStream |
getInputStream() |
OutputStream |
getOutputStream() |
protected String |
getProtocol() |
protected static String |
getProxyAuthString() |
static String |
getProxyBasicCredentials(String proxyHost,
int proxyPort,
String authHeader,
URL requestUrl) |
int |
getReadTimeout() |
Map |
getRequestProperties() |
String |
getRequestProperty(String key) |
int |
getResponseCode() |
static String |
getServerBasicCredentials(URL requestUrl,
String authHeader) |
SocketFactory |
getSocketFactory()
Gets the
SocketFactory to be used when creating sockets
for http URL connections. |
int |
getTimeout()
Deprecated.
since 9.0. Use getReadTimeout() instead
|
void |
setChunkedStreamingMode(int chunkLength) |
void |
setConnectTimeout(int i) |
static void |
setDefaultSocketFactory(SocketFactory nuDefaultSF)
Sets the default SocketFactory to be used when creating sockets for
http URL connections.
|
void |
setEmptyRequestProperty(String key) |
void |
setFixedLengthStreamingMode(int fixedContentLength) |
void |
setIgnoreProxy(boolean v)
This method will permit the current connection to ignore the system
property http.Proxy or inst Proxy
Note: this method only takes effect calling before the connect() method
|
void |
setIgnoreSystemNonProxyHosts(boolean v)
This method will permit the current connection ignore the system property http.nonProxyHosts
Note: this method only takes effect calling before the connect() method
|
void |
setMuxableSocket(Object socket) |
void |
setReadTimeout(int i) |
void |
setRequestMethod(String method) |
void |
setRequestProperty(String key,
String value) |
void |
setSocketFactory(SocketFactory fact)
Sets the
SocketFactory to be used when creating sockets
for http URL connections. |
void |
setTimeout(int i)
Deprecated.
since 9.0. Use setReadTimeout(int) instead
|
boolean |
usingProxy() |
protected void |
writeRequests() |
getFollowRedirects, getHeaderFieldDate, getInstanceFollowRedirects, getPermission, getRequestMethod, getResponseMessage, setFixedLengthStreamingMode, setFollowRedirects, setInstanceFollowRedirectsgetAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderFieldInt, getHeaderFieldLong, getIfModifiedSince, getLastModified, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setUseCaches, toStringprotected static int defaultConnectTimeout
protected IOException rememberedException
protected boolean ignoreSystemNonProxyHosts
protected boolean ignoreProxy
protected String getProtocol()
public final void setSocketFactory(SocketFactory fact)
SocketFactory to be used when creating sockets
for http URL connections.public final SocketFactory getSocketFactory()
SocketFactory to be used when creating sockets
for http URL connections.public static void setDefaultSocketFactory(SocketFactory nuDefaultSF)
nuDefaultSF - SocketFactory to be used as a default SocketFactoryprotected void writeRequests()
throws IOException
IOExceptionpublic void setIgnoreSystemNonProxyHosts(boolean v)
v - public void setIgnoreProxy(boolean v)
v - public void connect()
throws IOException
connect in class URLConnectionIOExceptionprotected HttpClient getHttpClient() throws IOException
IOExceptionpublic OutputStream getOutputStream() throws IOException
getOutputStream in class URLConnectionIOExceptionprotected static String getProxyAuthString()
public static String getAuthInfo(String host, int port, String header) throws IOException
IOExceptionpublic static String getProxyBasicCredentials(String proxyHost, int proxyPort, String authHeader, URL requestUrl) throws IOException
IOExceptionpublic static String getServerBasicCredentials(URL requestUrl, String authHeader) throws IOException
IOExceptionpublic InputStream getInputStream() throws IOException
getInputStream in class URLConnectionIOExceptionpublic InputStream getErrorStream()
getErrorStream in class HttpURLConnectionprotected boolean followRedirect()
throws IOException
IOExceptionpublic void disconnect()
disconnect in class HttpURLConnectionpublic boolean usingProxy()
usingProxy in class HttpURLConnectionpublic String getHeaderField(String name)
getHeaderField in class URLConnectionname - the name of the header fieldpublic String getHeaderField(int n)
getHeaderField in class HttpURLConnectionn - the index of the header fieldpublic Map getHeaderFields()
getHeaderFields in class URLConnectionpublic String getHeaderFieldKey(int n)
getHeaderFieldKey in class HttpURLConnectionn - the index of the header fieldpublic void addRequestProperty(String key, String value)
addRequestProperty in class URLConnectionkey - - request header namevalue - - request header valuepublic Map getRequestProperties()
getRequestProperties in class URLConnectionpublic void setRequestProperty(String key, String value)
setRequestProperty in class URLConnectionpublic void setEmptyRequestProperty(String key)
public String getRequestProperty(String key)
getRequestProperty in class URLConnectionprotected void doSetRequests()
public void setTimeout(int i)
i - in millisecondspublic int getTimeout()
public void setReadTimeout(int i)
setReadTimeout in class URLConnectionpublic int getReadTimeout()
getReadTimeout in class URLConnectionpublic void setConnectTimeout(int i)
setConnectTimeout in class URLConnectionpublic int getConnectTimeout()
getConnectTimeout in class URLConnectionpublic void setFixedLengthStreamingMode(int fixedContentLength)
setFixedLengthStreamingMode in class HttpURLConnectionpublic void setChunkedStreamingMode(int chunkLength)
setChunkedStreamingMode in class HttpURLConnectionpublic int getResponseCode()
throws IOException
getResponseCode in class HttpURLConnectionIOExceptionpublic void setMuxableSocket(Object socket)
public void setRequestMethod(String method) throws ProtocolException
setRequestMethod in class HttpURLConnectionProtocolException