net.i2p.util
Class EepGet

java.lang.Object
  extended by net.i2p.util.EepGet
Direct Known Subclasses:
EepHead, I2PSocketEepGet, PartialEepGet, SSLEepGet

public class EepGet
extends java.lang.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
protected  class EepGet.CLIStatusListener
           
static interface EepGet.StatusListener
           
 
Field Summary
protected  boolean _aborted
           
protected  java.lang.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  I2PAppContext _context
           
protected  int _currentAttempt
           
protected  boolean _encodingChunked
           
protected  long _fetchInactivityTimeout
           
protected  boolean _headersRead
           
protected  boolean _keepFetching
           
protected  java.util.List<EepGet.StatusListener> _listeners
           
protected  Log _log
           
protected  boolean _notModified
           
protected  int _numRetries
           
protected  java.io.OutputStream _out
           
protected  java.lang.String _outputFile
           
protected  java.io.OutputStream _outputStream
           
protected  java.net.Socket _proxy
           
protected  java.io.InputStream _proxyIn
           
protected  java.io.OutputStream _proxyOut
           
protected  java.lang.String _redirectLocation
           
protected  int _redirects
           
protected  boolean _shouldProxy
           
protected  boolean _transferFailed
           
protected  java.lang.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 java.lang.String USER_AGENT
          this will be replaced by the HTTP Proxy if we are using it
 
Constructor Summary
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, java.lang.String outputFile, java.io.OutputStream outputStream, java.lang.String url, boolean allowCaching, java.lang.String etag, java.lang.String postData)
           
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, java.lang.String outputFile, java.io.OutputStream outputStream, java.lang.String url, boolean allowCaching, java.lang.String etag, java.lang.String lastModified, java.lang.String postData)
           
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url)
           
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url, boolean allowCaching, java.lang.String etag)
           
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url, boolean allowCaching, java.lang.String etag, java.lang.String lastModified)
           
EepGet(I2PAppContext ctx, boolean shouldProxy, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url, java.lang.String postData)
           
EepGet(I2PAppContext ctx, int numRetries, java.lang.String outputFile, java.lang.String url)
           
EepGet(I2PAppContext ctx, int numRetries, java.lang.String outputFile, java.lang.String url, boolean allowCaching)
           
EepGet(I2PAppContext ctx, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url)
           
EepGet(I2PAppContext ctx, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String outputFile, java.lang.String url, boolean allowCaching)
           
 
Method Summary
 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)
           
 java.lang.String getContentType()
           
 java.lang.String getETag()
           
 java.lang.String getLastModified()
           
 boolean getNotModified()
           
protected  java.lang.String getRequest()
           
static void main(java.lang.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 java.lang.String suggestName(java.lang.String url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_context

protected I2PAppContext _context

_log

protected Log _log

_shouldProxy

protected boolean _shouldProxy

_numRetries

protected int _numRetries

_outputFile

protected java.lang.String _outputFile

_outputStream

protected java.io.OutputStream _outputStream

_url

protected java.lang.String _url
url we were asked to fetch


_actualURL

protected java.lang.String _actualURL
the URL we actually fetch from (may differ from the _url in case of redirect)


_listeners

protected final java.util.List<EepGet.StatusListener> _listeners

_keepFetching

protected boolean _keepFetching

_proxy

protected java.net.Socket _proxy

_proxyOut

protected java.io.OutputStream _proxyOut

_proxyIn

protected java.io.InputStream _proxyIn

_out

protected java.io.OutputStream _out

_alreadyTransferred

protected long _alreadyTransferred

_bytesTransferred

protected long _bytesTransferred

_bytesRemaining

protected long _bytesRemaining

_currentAttempt

protected int _currentAttempt

_encodingChunked

protected boolean _encodingChunked

_notModified

protected boolean _notModified

_transferFailed

protected boolean _transferFailed

_headersRead

protected boolean _headersRead

_aborted

protected boolean _aborted

_fetchInactivityTimeout

protected long _fetchInactivityTimeout

_redirects

protected int _redirects

_redirectLocation

protected java.lang.String _redirectLocation

USER_AGENT

protected static final java.lang.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,
              java.lang.String proxyHost,
              int proxyPort,
              int numRetries,
              java.lang.String outputFile,
              java.lang.String url)

EepGet

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

EepGet

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

EepGet

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

EepGet

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

EepGet

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

EepGet

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

EepGet

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

EepGet

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

EepGet

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

main

public static void main(java.lang.String[] args)
EepGet [-p 127.0.0.1:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url


suggestName

public static java.lang.String suggestName(java.lang.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 java.io.IOException
single fetch

Throws:
java.io.IOException

readHeaders

protected void readHeaders()
                    throws java.io.IOException
Throws:
java.io.IOException

readChunkLength

protected long readChunkLength()
                        throws java.io.IOException
Throws:
java.io.IOException

sendRequest

protected void sendRequest(SocketTimeout timeout)
                    throws java.io.IOException
Throws:
java.io.IOException

getRequest

protected java.lang.String getRequest()
                               throws java.io.IOException
Throws:
java.io.IOException

getETag

public java.lang.String getETag()

getLastModified

public java.lang.String getLastModified()

getNotModified

public boolean getNotModified()

getContentType

public java.lang.String getContentType()