java.lang.Object
net.i2p.util.EepGet
net.i2p.util.PartialEepGet

public class PartialEepGetextends EepGet
Fetch exactly the first 'size' bytes into a stream Anything less or more will throw an IOException Retries may be given; zero for no retries. If the server does not return a Content-Length header of the correct size, the fetch will fail.

Useful for checking .sud versions.

  • Field Details

    • _fetchSize

      private final long _fetchSize
      Size of the byte range to fetch.
  • Constructor Details

    • PartialEepGet

      public PartialEepGet(I2PAppContext ctx, String proxyHost, int proxyPort, OutputStream outputStream, String url, long size)
      Instantiate an EepGet that will fetch exactly size bytes when fetch() is called. Uses EepGet.DEFAULT_NUM_RETRIES retries so a transient empty or flaky upstream response does not immediately declare the source dead.
      Parameters:
      ctx - the I2P app context
      proxyHost - use null or "" for no proxy
      proxyPort - use 0 for no proxy
      outputStream - the stream to write output to
      url - the URL to fetch
      size - fetch exactly this many bytes
    • PartialEepGet

      public PartialEepGet(I2PAppContext ctx, String proxyHost, int proxyPort, OutputStream outputStream, String url, long size, int numRetries)
      Instantiate an EepGet that will fetch exactly size bytes when fetch() is called.
      Parameters:
      ctx - the I2P app context
      proxyHost - use null or "" for no proxy
      proxyPort - use 0 for no proxy
      outputStream - the stream to write output to
      url - the URL to fetch
      size - fetch exactly this many bytes
      numRetries - number of attempts (beyond the first) before giving up; 0 for no retries
  • Method Details

    • main

      public static void main(String[] args)
      Entry point for command-line usage.
      Parameters:
      args - command line arguments
    • usage

      private static void usage()
      Prints how to fetch part of a file from the command line.
    • getRequest

      protected String getRequest() throws IOException
      Description copied from class: EepGet
      Build the HTTP request string for the current URL and state.
      Overrides:
      getRequest in class EepGet
      Returns:
      the HTTP request string
      Throws:
      IOException - on bad URL