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(: 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.
|
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.
|
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.
|
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 alw |