Package sun.net.www.http
Class HttpClient
- java.lang.Object
-
- sun.net.NetworkClient
-
- sun.net.www.http.HttpClient
-
public class HttpClient extends NetworkClient
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringhostprotected intportbooleanreusestatic StringSOCKET_CONNECT_ACTIONstatic StringSOCKET_RESOLVE_ACTIONprotected URLurlUrl being fetched.-
Fields inherited from class sun.net.NetworkClient
connectTimeout, DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT, defaultConnectTimeout, defaultSoTimeout, encoding, readTimeout, serverInput, serverOutput, serverSocket
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpClient()protectedHttpClient(URL url, int to)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanavailable()static voidcheckConnect(SecurityManager sm, String host, int port)voidcloseIdleConnection()voidcloseServer()Close an open connection to the server.voidfinished()protected intgetDefaultPort()return default port number (subclasses may override)InputStreamgetInputStream()OutputStreamgetOutputStream()StringgetURLFile()static HttpClientNew(URL url)static HttpClientNew(URL url, int to, HttpURLConnection httpuc)protected voidopenServer()voidopenServer(String server, int port)Open a connection to the server.booleanparseHTTP(MessageHeader responses, HttpURLConnection httpuc)Parse the first line of the HTTP request.voidsetDoNotRetry(boolean value)voidsetIgnoreContinue(boolean value)static String[]splitWhitespace(String str)String.split("\\s+") <=> split()StringtoString()Returns a string representation of the object.voidwriteRequests(MessageHeader head, PosterOutputStream pos)voidwriteRequests(MessageHeader head, PosterOutputStream pos, boolean streaming)-
Methods inherited from class sun.net.NetworkClient
createSocket, doConnect, getConnectTimeout, getReadTimeout, serverIsOpen, setConnectTimeout, setReadTimeout
-
-
-
-
Field Detail
-
port
protected int port
-
url
protected URL url
Url being fetched.
-
reuse
public boolean reuse
-
SOCKET_RESOLVE_ACTION
public static final String SOCKET_RESOLVE_ACTION
- See Also:
- Constant Field Values
-
SOCKET_CONNECT_ACTION
public static final String SOCKET_CONNECT_ACTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpClient
protected HttpClient()
-
HttpClient
protected HttpClient(URL url, int to) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getDefaultPort
protected int getDefaultPort()
return default port number (subclasses may override)
-
New
public static HttpClient New(URL url) throws IOException
- Throws:
IOException
-
New
public static HttpClient New(URL url, int to, @Nullable HttpURLConnection httpuc) throws IOException
- Throws:
IOException
-
finished
public void finished()
-
available
protected boolean available()
-
closeIdleConnection
public void closeIdleConnection()
-
openServer
public void openServer(String server, int port) throws IOException
Description copied from class:NetworkClientOpen a connection to the server.- Overrides:
openServerin classNetworkClient- Throws:
IOException
-
openServer
protected void openServer() throws IOException- Throws:
IOException
-
getURLFile
public String getURLFile() throws IOException
- Throws:
IOException
-
writeRequests
public void writeRequests(MessageHeader head, PosterOutputStream pos) throws IOException
- Throws:
IOException
-
writeRequests
public void writeRequests(MessageHeader head, PosterOutputStream pos, boolean streaming) throws IOException
- Throws:
IOException
-
parseHTTP
public boolean parseHTTP(MessageHeader responses, HttpURLConnection httpuc) throws IOException
Parse the first line of the HTTP request. It usually looks something like: "HTTP/1.0 <number> comment\r\n".- Throws:
IOException
-
getInputStream
@Nullable public InputStream getInputStream()
-
getOutputStream
@Nullable public OutputStream getOutputStream()
-
toString
public String toString()
Description copied from class:ObjectReturns a string representation of the object. In general, thetoStringmethod returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.The
toStringmethod for classObjectreturns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:getClass().getName() + '@' + Integer.toHexString(hashCode())
-
splitWhitespace
public static String[] splitWhitespace(String str)
String.split("\\s+") <=> split()
-
setDoNotRetry
public void setDoNotRetry(boolean value)
-
setIgnoreContinue
public void setIgnoreContinue(boolean value)
-
closeServer
public void closeServer()
Description copied from class:NetworkClientClose an open connection to the server.- Overrides:
closeServerin classNetworkClient
-
checkConnect
public static void checkConnect(SecurityManager sm, String host, int port)
-
-