Unit | addRequestProperty(key: String!, value: String!) Adds a general request property specified by a key-value pair. This method will not overwrite existing values associated with the same key. |
Unit | connect() Opens a communications link to the resource referenced by this URL, if such a connection has not already been established. If the connect method is called when the connection has already been opened (indicated by the connected field having the value true ), the call is ignored. URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary. |
Boolean | getAllowUserInteraction() Returns the value of the allowUserInteraction field for this object. |
Int | getConnectTimeout() Returns setting for connect timeout. 0 return implies that the option is disabled (i.e., timeout of infinity). |
Any! | getContent() Retrieves the contents of this URL connection. This method first determines the content type of the object by calling the getContentType method. If this is the first time that the application has seen that specific content type, a content handler for that content type is created: - If the application has set up a content handler factory instance using the
setContentHandlerFactory method, the createContentHandler method of that instance is called with the content type as an argument; the result is a content handler for that content type. - If no content handler factory has yet been set up, or if the factory's
createContentHandler method returns null , then the application loads the class named: sun.net.www.content.<<i>contentType</i>> where <contentType> is formed by taking the content-type string, replacing all slash characters with a period ('.'), and all other non-alphanumeric characters with the underscore character '_ '. The alphanumeric characters are specifically the 26 uppercase ASCII letters 'A ' through 'Z ', the 26 lowercase ASCII letters 'a ' through 'z ', and the 10 ASCII digits '0 ' through '9 '. If the specified class does not exist, or is not a subclass of ContentHandler , then an UnknownServiceException is thrown. |
Any! | getContent(classes: Array<Class<Any!>!>!) Retrieves the contents of this URL connection. |
String! | getContentEncoding() Returns the value of the content-encoding header field. |
Int | getContentLength() Returns the value of the content-length header field. Note: getContentLengthLong() should be preferred over this method, since it returns a long instead and is therefore more portable. |
Long | getContentLengthLong() Returns the value of the content-length header field as a long. |
String! | getContentType() Returns the value of the content-type header field. |
Long | getDate() Returns the value of the date header field. |
Boolean | getDefaultAllowUserInteraction() Returns the default value of the allowUserInteraction field. Ths default is "sticky", being a part of the static state of all URLConnections. This flag applies to the next, and all following URLConnections that are created. |
String! | getDefaultRequestProperty(key: String!) Returns the value of the default request property. Default request properties are set for every connection. |
Boolean | getDefaultUseCaches() Returns the default value of a URLConnection 's useCaches flag. Ths default is "sticky", being a part of the static state of all URLConnections. This flag applies to the next, and all following URLConnections that are created. |
Boolean | getDoInput() Returns the value of this URLConnection 's doInput flag. |
Boolean | getDoOutput() Returns the value of this URLConnection 's doOutput flag. |
Long | getExpiration() Returns the value of the expires header field. |
FileNameMap! | getFileNameMap() Returns a FileNameMap implementation suitable for guessing a content type based on a URL's "file" component. |
String! | getHeaderField(: Int) Returns the value for the n th header field. It returns null if there are fewer than n+1 fields. This method can be used in conjunction with the getHeaderFieldKey method to iterate through all the headers in the message. |
String! | getHeaderField(: String!) Returns the value of the named header field. If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned. |
Long | getHeaderFieldDate(: String!, : Long) Returns the value of the named field parsed as date. The result is the number of milliseconds since January 1, 1970 GMT represented by the named field. This form of getHeaderField exists because some connection types (e.g., http-ng ) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing. |
Int | getHeaderFieldInt(: String!, : Int) Returns the value of the named field parsed as a number. This form of getHeaderField exists because some connection types (e.g., http-ng ) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing. |
String! | getHeaderFieldKey(: Int) Returns the key for the n th header field. It returns null if there are fewer than n+1 fields. |
Long | getHeaderFieldLong(: String!, : Long) Returns the value of the named field parsed as a number. This form of getHeaderField exists because some connection types (e.g., http-ng ) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing. |
MutableMap<String!, MutableList<String!>!>! | getHeaderFields() Returns an unmodifiable Map of the header fields. The Map keys are Strings that represent the response-header field names. Each Map value is an unmodifiable List of Strings that represents the corresponding field values. |
Long | getIfModifiedSince() Returns the value of this object's ifModifiedSince field. |
InputStream! | getInputStream() Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read. |
Long | getLastModified() Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT. |
OutputStream! | getOutputStream() Returns an output stream that writes to this connection. |
Permission! | getPermission() Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns java.security.AllPermission . Subclasses should override this method and return the permission that best represents the permission required to make a a connection to the URL. For example, a URLConnection representing a file: URL would return a java.io.FilePermission object. The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com. Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained after the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested before connecting. |
Int | getReadTimeout() Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity). |
MutableMap<String!, MutableList<String!>!>! | getRequestProperties() Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names. Each Map value is a unmodifiable List of Strings that represents the corresponding field values. |
String! | getRequestProperty(key: String!) Returns the value of the named general request property for this connection. |
URL! | getURL() Returns the value of this URLConnection 's URL field. |
Boolean | getUseCaches() Returns the value of this URLConnection 's useCaches field. |
String! | guessContentTypeFromName(fname: String!) Tries to determine the content type of an object, based on the specified "file" component of a URL. This is a convenience method that can be used by subclasses that override the getContentType method. |
String! | guessContentTypeFromStream(is: InputStream!) Tries to determine the type of an input stream based on the characters at the beginning of the input stream. This method can be used by subclasses that override the getContentType method. Ideally, this routine would not be needed. But many http servers return the incorrect content type; in addition, there are many nonstandard extensions. Direct inspection of the bytes to determine the content type is often more accurate than believing the content type claimed by the http server. |
Unit | setAllowUserInteraction(allowuserinteraction: Boolean) Set the value of the allowUserInteraction field of this URLConnection . |
Unit | setConnectTimeout(timeout: Int) Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. Some non-standard implementation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout(). Warning: If the hostname resolves to multiple IP addresses, Android's default implementation of HttpURLConnection will try each in RFC 3484 order. If connecting to each of these addresses fails, multiple timeouts will elapse before the connect attempt throws an exception. Host names that support both IPv6 and IPv4 always have at least 2 IP addresses. |
Unit | setContentHandlerFactory(fac: ContentHandlerFactory!) Sets the ContentHandlerFactory of an application. It can be called at most once by an application. The ContentHandlerFactory instance is used to construct a content handler from a content type If there is a security manager, this method first calls the security manager's checkSetFactory method to ensure the operation is allowed. This could result in a SecurityException. |
Unit | setDefaultAllowUserInteraction(defaultallowuserinteraction: Boolean) Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value. |
Unit | setDefaultRequestProperty(key: String!, value: String!) Sets the default value of a general request property. When a URLConnection is created, it is initialized with these properties. |
Unit | setDefaultUseCaches(defaultusecaches: Boolean) Sets the default value of the useCaches field to the specified value. |
Unit | setDoInput(doinput: Boolean) Sets the value of the doInput field for this URLConnection to the specified value. A URL connection can be used for input and/or output. Set the DoInput flag to true if you intend to use the URL connection for input, false if not. The default is true. |
Unit | setDoOutput(dooutput: Boolean) Sets the value of the doOutput field for this URLConnection to the specified value. A URL connection can be used for input and/or output. Set the DoOutput flag to true if you intend to use the URL connection for output, false if not. The default is false. |
Unit | setFileNameMap(map: FileNameMap!) Sets the FileNameMap. If there is a security manager, this method first calls the security manager's checkSetFactory method to ensure the operation is allowed. This could result in a SecurityException. |
Unit | setIfModifiedSince(ifmodifiedsince: Long) Sets the value of the ifModifiedSince field of this URLConnection to the specified value. |
Unit | setReadTimeout(timeout: Int) Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. Some non-standard implementation of this method ignores the specified timeout. To see the read timeout set, please call getReadTimeout(). |
Unit | setRequestProperty(key: String!, value: String!) Sets the general request property. If a property with the key already exists, overwrite its value with the new value. NOTE: HTTP requires all request properties which can legally have multiple instances with the same key to use a comma-separated list syntax which enables multiple properties to be appended into a single property. |
Unit | setUseCaches(usecaches: Boolean) Sets the value of the useCaches field of this URLConnection to the specified value. Some protocols do caching of documents. Occasionally, it is important to be able to "tunnel through" and ignore the caches (e.g., the "reload" button in a browser). If the UseCaches flag on a connection is true, the connection is allowed to use whatever caches it can. If false, caches are to be ignored. The default value comes from DefaultUseCaches, which defaults to true. |
String | toString() Returns a String representation of this URL connection. |