public class EepHead extends EepGet
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.EepGet.AUTH_MODE, EepGet.AuthState, EepGet.CLIStatusListener, EepGet.Gunzipper, EepGet.StatusListener_aborted, _acceptRanges, _actualURL, _alreadyTransferred, _authState, _bytesRemaining, _bytesTransferred, _cacheControl, _contentEncoding, _contentLanguage, _contentType, _context, _cookie, _csp, _currentAttempt, _decompressException, _encodingChunked, _etag, _etagOrig, _expiryDate, _extraHeaders, _fetchHeaderTimeout, _fetchInactivityTimeout, _fetchTotalTimeout, _isGzippedResponse, _keepFetching, _lastModified, _lastModifiedOrig, _listeners, _log, _maxCompleteFails, _notModified, _numRetries, _out, _outputFile, _outputStream, _proxy, _proxyHost, _proxyIn, _proxyOut, _proxyPort, _redirectLocation, _redirects, _referrerPolicy, _responseCode, _responseText, _server, _shouldProxy, _shouldWriteErrorToOutput, _status, _transferEncoding, _transferFailed, _url, _vary, _xContentTypeOptions, _xframeOptions, _xPoweredBy, _xssProtection, DEFAULT_CONNECT_TIMEOUT, DEFAULT_INACTIVITY_TIMEOUT, DEFAULT_MAX_COMPLETE_FAILS, DEFAULT_NUM_RETRIES, PROP_CONNECT_TIMEOUT, PROP_DEFAULT_RETRIES, PROP_INACTIVITY_TIMEOUT, PROP_MAX_COMPLETE_FAILS, USER_AGENT| Constructor and Description |
|---|
EepHead(I2PAppContext ctx,
String proxyHost,
int proxyPort,
int numRetries,
String url)Create a new EepHead to fetch HTTP response headers from the given URL. |
| Modifier and Type | Method and Description |
|---|---|
protected void | doFetch(SocketTimeout timeout)Read the response headers and notify listeners. |
long | getContentLength()We don't decrement the variable (unlike in EepGet), so this is valid |
protected String | getRequest()Build the HTTP HEAD request, including headers for Host, User-Agent, and proxy auth. |
static void | main(String[] args)CLI entry point: fetch and display HTTP response headers for a URL. |
protected boolean | shouldReadBody()Should we read the body of the response? |
addAuthorization, addHeader, addStatusListener, fetch, fetch, fetch, getAcceptRanges, getCacheControl, getContentEncoding, getContentLanguage, getContentType, getCookie, getCSP, getEtag, getExpiryDate, getLastModified, getNotModified, getReferrerPolicy, getServer, getStatus, getStatusCode, getStatusText, getTransferEncoding, getVary, getXContentTypeOptions, getXframeOptions, getXPoweredBy, getXSSProtection, parseAuthArgs, readChunkLength, readHeaders, sendRequest, setPostData, setPostData, setPostData, setWriteErrorToOutput, stopFetching, suggestNamepublic EepHead(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String url)
ctx - I2P app contextproxyHost - proxy hostnameproxyPort - proxy portnumRetries - number of retries on failureurl - target URLprotected void doFetch(SocketTimeout timeout) throws IOException
doFetch in class EepGettimeout - may be null as of 0.9.49IOException - on IO errorpublic long getContentLength()
protected String getRequest() throws IOException
getRequest in class EepGetIOException - on bad URLpublic static void main(String[] args)
protected boolean shouldReadBody()
shouldReadBody in class EepGet