Class DataURLConnection
java.lang.Object
java.net.URLConnection
com.github.robtimus.net.protocol.data.DataURLConnection
A connection to a
data: URL as specified in RFC 2397.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]private InputStreamprivate final MediaTypeFields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Returns the content encoding of the data URL.intReturns the length of the decoded data part of the data URL.longReturns the length of the decoded data part of the data URL.Returns the media type of the data URL.Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
Field Details
-
mediaType
-
data
private final byte[] data -
inputStream
-
-
Constructor Details
-
DataURLConnection
-
-
Method Details
-
connect
public void connect()- Specified by:
connectin classURLConnection
-
getContentLength
public int getContentLength()Returns the length of the decoded data part of the data URL.- Overrides:
getContentLengthin classURLConnection- Returns:
- The length of the decoded data part of the data URL.
-
getContentLengthLong
public long getContentLengthLong()Returns the length of the decoded data part of the data URL.- Overrides:
getContentLengthLongin classURLConnection- Returns:
- The length of the decoded data part of the data URL.
-
getContentType
Returns the media type of the data URL. If none is specified it will betext/plain;charset=US-ASCII, as specified in RFC 2397.- Overrides:
getContentTypein classURLConnection- Returns:
- The media type of the data URL.
-
getContentEncoding
Returns the content encoding of the data URL. This is taken from the data URL's media type.If no media type is specified, it is assumed to be
text/plain;charset=US-ASCII, as specified in RFC 2397. As a result, the content encoding will then beUS-ASCII.- Overrides:
getContentEncodingin classURLConnection- Returns:
- The content encoding of the data URL.
-
getInputStream
- Overrides:
getInputStreamin classURLConnection- Throws:
IOException
-