net.i2p.util

## Class EepGet

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

- Direct Known Subclasses:
    EepHead, I2PSocketEepGet, PartialEepGet, SSLEepGet

      public class EepGet
      extends Object

  EepGet [-p 127.0.0.1:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] url Bug: a malformed url http://example.i2p (no trailing '/') fails cryptically

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `EepGet.CLIStatusListener`
    `static interface` | `EepGet.StatusListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_aborted`
    `protected String` | `_actualURL` the URL we actually fetch from (may differ from the _url in case of redirect)
    `protected long` | `_alreadyTransferred`
    `protected long` | `_bytesRemaining`
    `protected long` | `_bytesTransferred`
    `protected String` | `_contentType`
    `protected I2PAppContext` | `_context`
    `protected int` | `_currentAttempt`
    `protected boolean` | `_encodingChunked`
    `protected String` | `_etag`
    `protected long` | `_fetchInactivityTimeout`
    `protected boolean` | `_headersRead`
    `protected boolean` | `_keepFetching`
    `protected String` | `_lastModified`
    `protected List<EepGet.StatusListener>` | `_listeners`
    `protected Log` | `_log`
    `protected boolean` | `_notModified`
    `protected int` | `_numRetries`
    `protected OutputStream` | `_out`
    `protected String` | `_outputFile`
    `protected OutputStream` | `_outputStream`
    `protected Socket` | `_proxy`
    `protected InputStream` | `_proxyIn`
    `protected OutputStream` | `_proxyOut`
    `protected String` | `_redirectLocation`
    `protected int` | `_redirects`
    `protected boolean` | `_shouldProxy`
    `protected boolean` | `_transferFailed`
    `protected String` | `_url` url we were asked to fetch
    `protected static long` | `CONNECT_TIMEOUT`
    `protected static long` | `INACTIVITY_TIMEOUT`
    `protected static int` | `MAX_COMPLETE_FAILS` maximum times to try without getting any data at all, even if numRetries is higher @since 0.7.14
    `protected static String` | `USER_AGENT` this will be replaced by the HTTP Proxy if we are using it

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData)`
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String lastModified, String postData)`
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url)`
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag)`
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag, String lastModified)`
    `EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, String postData)`
    `EepGet(I2PAppContext ctx, int numRetries, String outputFile, String url)`
    `EepGet(I2PAppContext ctx, int numRetries, String outputFile, String url, boolean allowCaching)`
    `EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url)`
    `EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addStatusListener(EepGet.StatusListener lsnr)`
    `protected void` | `doFetch(SocketTimeout timeout)` single fetch
    `boolean` | `fetch()` Blocking fetch, returning true if the URL was retrieved, false if all retries failed
    `boolean` | `fetch(long fetchHeaderTimeout)` Blocking fetch, timing out individual attempts if the HTTP response headers don't come back in the time given.
    `boolean` | `fetch(long fetchHeaderTimeout, long totalTimeout, long inactivityTimeout)`
    `String` | `getContentType()`
    `String` | `getETag()`
    `String` | `getLastModified()`
    `boolean` | `getNotModified()`
    `protected String` | `getRequest()`
    `static void` | `main(String[] args)` EepGet [-p 127.0.0.1:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url
    `protected long` | `readChunkLength()`
    `protected void` | `readHeaders()`
    `protected void` | `sendRequest(SocketTimeout timeout)`
    `void` | `stopFetching()`
    `static String` | `suggestName(String url)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _context

          protected final I2PAppContext _context

    - #### _log

          protected final Log _log

    - #### _shouldProxy

          protected final boolean _shouldProxy

    - #### _numRetries

          protected final int _numRetries

    - #### _outputFile

          protected final String _outputFile

    - #### _outputStream

          protected final OutputStream _outputStream

    - #### _url

          protected final String _url

      url we were asked to fetch

    - #### _actualURL

          protected String _actualURL

      the URL we actually fetch from (may differ from the _url in case of redirect)

    - #### _listeners

          protected final List<EepGet.StatusListener> _listeners

    - #### _keepFetching

          protected boolean _keepFetching

    - #### _proxy

          protected Socket _proxy

    - #### _proxyOut

          protected OutputStream _proxyOut

    - #### _proxyIn

          protected InputStream _proxyIn

    - #### _out

          protected OutputStream _out

    - #### _alreadyTransferred

          protected long _alreadyTransferred

    - #### _bytesTransferred

          protected long _bytesTransferred

    - #### _bytesRemaining

          protected long _bytesRemaining

    - #### _currentAttempt

          protected int _currentAttempt

    - #### _etag

          protected String _etag

    - #### _lastModified

          protected String _lastModified

    - #### _encodingChunked

          protected boolean _encodingChunked

    - #### _notModified

          protected boolean _notModified

    - #### _contentType

          protected String _contentType

    - #### _transferFailed

          protected boolean _transferFailed

    - #### _headersRead

          protected boolean _headersRead

    - #### _aborted

          protected boolean _aborted

    - #### _fetchInactivityTimeout

          protected long _fetchInactivityTimeout

    - #### _redirects

          protected int _redirects

    - #### _redirectLocation

          protected String _redirectLocation

    - #### USER_AGENT

          protected static final String USER_AGENT

      this will be replaced by the HTTP Proxy if we are using it
      See Also:
        Constant Field Values

    - #### CONNECT_TIMEOUT

          protected static final long CONNECT_TIMEOUT

      See Also:
        Constant Field Values

    - #### INACTIVITY_TIMEOUT

          protected static final long INACTIVITY_TIMEOUT

      See Also:
        Constant Field Values

    - #### MAX_COMPLETE_FAILS

          protected static final int MAX_COMPLETE_FAILS

      maximum times to try without getting any data at all, even if numRetries is higher @since 0.7.14
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url,
                boolean allowCaching)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                int numRetries,
                String outputFile,
                String url)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                int numRetries,
                String outputFile,
                String url,
                boolean allowCaching)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url,
                String postData)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url,
                boolean allowCaching,
                String etag)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                String outputFile,
                String url,
                boolean allowCaching,
                String etag,
                String lastModified)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                long minSize,
                long maxSize,
                String outputFile,
                OutputStream outputStream,
                String url,
                boolean allowCaching,
                String etag,
                String postData)

    - #### EepGet

          public EepGet(I2PAppContext ctx,
                boolean shouldProxy,
                String proxyHost,
                int proxyPort,
                int numRetries,
                long minSize,
                long maxSize,
                String outputFile,
                OutputStream outputStream,
                String url,
                boolean allowCaching,
                String etag,
                String lastModified,
                String postData)

  - ### Method Detail

    - #### main

          public static void main(String[] args)

      EepGet [-p 127.0.0.1:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url

    - #### suggestName

          public static String suggestName(String url)

    - #### addStatusListener

          public void addStatusListener(EepGet.StatusListener lsnr)

    - #### stopFetching

          public void stopFetching()

    - #### fetch

          public boolean fetch()

      Blocking fetch, returning true if the URL was retrieved, false if all retries failed

    - #### fetch

          public boolean fetch(long fetchHeaderTimeout)

      Blocking fetch, timing out individual attempts if the HTTP response headers don't come back in the time given. If the timeout is zero or less, this will wait indefinitely.

    - #### fetch

          public boolean fetch(long fetchHeaderTimeout,
                      long totalTimeout,
                      long inactivityTimeout)

    - #### doFetch

          protected void doFetch(SocketTimeout timeout)
                          throws IOException

      single fetch
      Parameters:
        `timeout` - may be null
      Throws:
        `IOException`

    - #### readHeaders

          protected void readHeaders()
                              throws IOException

      Throws:
        `IOException`

    - #### readChunkLength

          protected long readChunkLength()
                                  throws IOException

      Throws:
        `IOException`

    - #### sendRequest

          protected void sendRequest(SocketTimeout timeout)
                              throws IOException

      Parameters:
        `timeout` - may be null
      Throws:
        `IOException`

    - #### getRequest

          protected String getRequest()
                               throws IOException

      Throws:
        `IOException`

    - #### getETag

          public String getETag()

    - #### getLastModified

          public String getLastModified()

    - #### getNotModified

          public boolean getNotModified()

    - #### getContentType

          public String getContentType()