net.i2p.util
Class EepHead

java.lang.Object
  extended by net.i2p.util.EepGet
      extended by net.i2p.util.EepHead

public class EepHead
extends EepGet

This is a quick hack to get a working EepHead, primarily for the following usage: EepHead foo = new EepHead(...); if (foo.fetch()) { String lastmod = foo.getLastModified(); if (lastmod != null) { parse the string... ... } } Other use cases (command line, listeners, etc...) lightly- or un-tested. Writing from scratch rather than extending EepGet would maybe have been less bloated memory-wise. This way gets us redirect handling, among other benefits.

Author:
zzz

Nested Class Summary
 
Nested classes/interfaces inherited from class net.i2p.util.EepGet
EepGet.CLIStatusListener, EepGet.StatusListener
 
Field Summary
(package private) static java.io.OutputStream _dummyStream
          EepGet needs either a non-null file or a stream... shouldn't actually be written to...
 
Fields inherited from class net.i2p.util.EepGet
_aborted, _actualURL, _alreadyTransferred, _bytesRemaining, _bytesTransferred, _context, _currentAttempt, _encodingChunked, _fetchInactivityTimeout, _headersRead, _keepFetching, _listeners, _log, _notModified, _numRetries, _out, _outputFile, _outputStream, _proxy, _proxyIn, _proxyOut, _redirectLocation, _redirects, _shouldProxy, _transferFailed, _url, CONNECT_TIMEOUT, INACTIVITY_TIMEOUT, MAX_COMPLETE_FAILS, USER_AGENT
 
Constructor Summary
EepHead(I2PAppContext ctx, java.lang.String proxyHost, int proxyPort, int numRetries, java.lang.String url)
           
 
Method Summary
protected  void doFetch(SocketTimeout timeout)
          return true if the URL was completely retrieved
 long getContentLength()
          We don't decrement the variable (unlike in EepGet), so this is valid
protected  java.lang.String getRequest()
           
static void main(java.lang.String[] args)
          EepHead [-p 127.0.0.1:4444] [-n #retries] url This doesn't really do much since it doesn't register a listener.
 
Methods inherited from class net.i2p.util.EepGet
addStatusListener, fetch, fetch, fetch, getContentType, getETag, getLastModified, getNotModified, readChunkLength, readHeaders, sendRequest, stopFetching, suggestName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dummyStream

static final java.io.OutputStream _dummyStream
EepGet needs either a non-null file or a stream... shouldn't actually be written to...

Constructor Detail

EepHead

public EepHead(I2PAppContext ctx,
               java.lang.String proxyHost,
               int proxyPort,
               int numRetries,
               java.lang.String url)
Method Detail

main

public static void main(java.lang.String[] args)
EepHead [-p 127.0.0.1:4444] [-n #retries] url This doesn't really do much since it doesn't register a listener. EepGet doesn't have a method to store and return all the headers, so just print out the ones we have methods for. Turn on logging to use it for a decent test.


doFetch

protected void doFetch(SocketTimeout timeout)
                throws java.io.IOException
return true if the URL was completely retrieved

Overrides:
doFetch in class EepGet
Throws:
java.io.IOException

getRequest

protected java.lang.String getRequest()
                               throws java.io.IOException
Overrides:
getRequest in class EepGet
Throws:
java.io.IOException

getContentLength

public long getContentLength()
We don't decrement the variable (unlike in EepGet), so this is valid