net.i2p.util
Class EepHead
java.lang.Object
net.i2p.util.EepGet
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.
Note that this follows redirects! This may not be what you want or expect.
Writing from scratch rather than extending EepGet would maybe have been less bloated memory-wise.
This way gets us redirect handling, among other benefits.
- Since:
- 0.7.7
- Author:
- zzz
Fields inherited from class net.i2p.util.EepGet |
_aborted, _actualURL, _alreadyTransferred, _bytesRemaining, _bytesTransferred, _contentType, _context, _currentAttempt, _decompressException, _encodingChunked, _etag, _extraHeaders, _fetchInactivityTimeout, _headersRead, _isGzippedResponse, _keepFetching, _lastModified, _listeners, _log, _notModified, _numRetries, _out, _outputFile, _outputStream, _proxy, _proxyIn, _proxyOut, _redirectLocation, _redirects, _responseCode, _shouldProxy, _shouldWriteErrorToOutput, _transferFailed, _url, CONNECT_TIMEOUT, INACTIVITY_TIMEOUT, MAX_COMPLETE_FAILS, USER_AGENT |
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 String |
getRequest()
|
static void |
main(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 |
addAuthorization, addHeader, addStatusListener, fetch, fetch, fetch, getContentType, getETag, getLastModified, getNotModified, getStatusCode, readChunkLength, readHeaders, sendRequest, setWriteErrorToOutput, stopFetching, suggestName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_dummyStream
static final OutputStream _dummyStream
- EepGet needs either a non-null file or a stream... shouldn't actually be written to...
EepHead
public EepHead(I2PAppContext ctx,
String proxyHost,
int proxyPort,
int numRetries,
String url)
main
public static void main(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 IOException
- return true if the URL was completely retrieved
- Overrides:
doFetch
in class EepGet
- Parameters:
timeout
- may be null
- Throws:
IOException
getRequest
protected String getRequest()
throws IOException
- Overrides:
getRequest
in class EepGet
- Throws:
IOException
getContentLength
public long getContentLength()
- We don't decrement the variable (unlike in EepGet), so this is valid