Class DataURLConnection

java.lang.Object
java.net.URLConnection
com.github.robtimus.net.protocol.data.DataURLConnection

public class DataURLConnection extends URLConnection
A connection to a data: URL as specified in RFC 2397.
  • Field Details

    • mediaType

      private final MediaType mediaType
    • data

      private final byte[] data
    • inputStream

      private InputStream inputStream
  • Constructor Details

    • DataURLConnection

      DataURLConnection(URL url, MediaType mediaType, byte[] data)
  • Method Details

    • connect

      public void connect()
      Specified by:
      connect in class URLConnection
    • getContentLength

      public int getContentLength()
      Returns the length of the decoded data part of the data URL.
      Overrides:
      getContentLength in class URLConnection
      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:
      getContentLengthLong in class URLConnection
      Returns:
      The length of the decoded data part of the data URL.
    • getContentType

      public String getContentType()
      Returns the media type of the data URL. If none is specified it will be text/plain;charset=US-ASCII, as specified in RFC 2397.
      Overrides:
      getContentType in class URLConnection
      Returns:
      The media type of the data URL.
    • getContentEncoding

      public String 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 be US-ASCII.

      Overrides:
      getContentEncoding in class URLConnection
      Returns:
      The content encoding of the data URL.
    • getInputStream

      public InputStream getInputStream() throws IOException
      Overrides:
      getInputStream in class URLConnection
      Throws:
      IOException