public class EepGet extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
EepGet.AUTH_MODE
Authentication mode enumeration.
|
protected class |
EepGet.AuthState
Manage the authentication parameters
Ref: RFC 2617
Supports both Basic and Digest, however i2ptunnel HTTP proxy
has migrated all previous Basic support to Digest.
|
protected class |
EepGet.CLIStatusListener |
protected class |
EepGet.Gunzipper
Decompressor thread.
|
static interface |
EepGet.StatusListener
Callback interface
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_aborted |
protected String |
_acceptRanges |
protected String |
_actualURL
the URL we actually fetch from (may differ from the _url in case of redirect)
|
protected long |
_alreadyTransferred |
protected EepGet.AuthState |
_authState |
protected long |
_bytesRemaining |
protected long |
_bytesTransferred |
protected String |
_cacheControl |
protected String |
_contentEncoding |
protected String |
_contentLanguage |
protected String |
_contentType |
protected I2PAppContext |
_context |
protected String |
_cookie |
protected String |
_csp |
protected int |
_currentAttempt |
protected IOException |
_decompressException |
protected boolean |
_encodingChunked |
protected String |
_etag |
protected String |
_etagOrig |
protected String |
_expiryDate |
protected List<String> |
_extraHeaders |
protected int |
_fetchHeaderTimeout |
protected int |
_fetchInactivityTimeout |
protected int |
_fetchTotalTimeout |
protected boolean |
_isGzippedResponse |
protected boolean |
_keepFetching |
protected String |
_lastModified |
protected String |
_lastModifiedOrig |
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 String |
_proxyHost |
protected InputStream |
_proxyIn |
protected OutputStream |
_proxyOut |
protected int |
_proxyPort |
protected String |
_redirectLocation |
protected int |
_redirects |
protected String |
_referrerPolicy |
protected int |
_responseCode |
protected String |
_responseText |
protected String |
_server |
protected boolean |
_shouldProxy |
protected boolean |
_shouldWriteErrorToOutput |
protected String |
_status |
protected String |
_transferEncoding |
protected boolean |
_transferFailed |
protected String |
_url
url we were asked to fetch
|
protected String |
_vary |
protected String |
_xContentTypeOptions |
protected String |
_xframeOptions |
protected String |
_xPoweredBy |
protected String |
_xssProtection |
protected static int |
CONNECT_TIMEOUT |
protected static int |
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 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) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAuthorization(String userName,
String password)
Add basic authorization header for the proxy.
|
void |
addHeader(String name,
String value)
Add an extra header to the request.
|
void |
addStatusListener(EepGet.StatusListener lsnr) |
protected void |
doFetch(SocketTimeout timeout)
This reads the response to a 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)
Blocking fetch.
|
String |
getAcceptRanges()
Show the Accept-Ranges field
|
String |
getCacheControl()
Show the Cache-Control field
|
String |
getContentEncoding()
Show the Content-Encoding field
|
String |
getContentLanguage()
Show the Content-Language field
|
String |
getContentType()
After fetch, the received value from the server, or null if none.
|
String |
getCookie()
Show the Set-Cookie field
|
String |
getCSP()
Show the Content-Security-Policy field
|
String |
getEtag()
After fetch, the received value from the server, or null if none.
|
String |
getExpiryDate()
Show the Expires field
|
String |
getLastModified()
After fetch, the received value from the server, or null if none.
|
boolean |
getNotModified() |
String |
getReferrerPolicy()
Show the Referrer-Policy field
|
protected String |
getRequest() |
String |
getServer()
Show the Server field
|
String |
getStatus()
Show a combined server status message e.g.
|
int |
getStatusCode()
The server response (200, etc).
|
String |
getStatusText()
The server text ("OK", "Not Found", etc).
|
String |
getTransferEncoding()
Show the Transfer-Encoding field
|
String |
getVary()
Show the Vary field
|
String |
getXContentTypeOptions()
Show the X-Content-Type-Options field
|
String |
getXframeOptions()
Show the X-frame-Options field
|
String |
getXPoweredBy()
Show the X-Powered-By field
|
String |
getXSSProtection()
Show the X-XSS-Protection field
|
static void |
main(String[] args)
EepGet [-p 127.0.0.1:4444] [-n #retries] [-e etag] [-o outputFile] [-m markSize lineLen] url
As of 0.9.45, supports https and redirect to https
|
static Map<String,String> |
parseAuthArgs(String args)
Parse the args in an authentication header.
|
protected long |
readChunkLength()
TODO this does not skip over chunk extensions (RFC 2616 sec.
|
protected void |
readHeaders() |
protected void |
sendRequest(SocketTimeout timeout) |
protected void |
setPostData(String contentType,
byte[] data)
Set post data.
|
protected void |
setPostData(String contentType,
File data)
Set post data.
|
protected void |
setPostData(String contentType,
String data)
Set post data.
|
void |
setWriteErrorToOutput()
If called (before calling fetch()),
data from the server or proxy will be written to the
output file or stream even on an error response code (4xx, 5xx, etc).
|
protected boolean |
shouldReadBody()
Should we read the body of the response?
|
void |
stopFetching() |
static String |
suggestName(String url)
Parse URL for a viable filename.
|
protected volatile boolean _aborted
protected String _acceptRanges
protected String _actualURL
protected long _alreadyTransferred
protected EepGet.AuthState _authState
protected long _bytesRemaining
protected long _bytesTransferred
protected String _cacheControl
protected String _contentEncoding
protected String _contentLanguage
protected String _contentType
protected final I2PAppContext _context
protected String _cookie
protected String _csp
protected int _currentAttempt
protected IOException _decompressException
protected volatile boolean _encodingChunked
protected String _etag
protected final String _etagOrig
protected String _expiryDate
protected volatile int _fetchHeaderTimeout
protected volatile int _fetchInactivityTimeout
protected volatile int _fetchTotalTimeout
protected boolean _isGzippedResponse
protected volatile boolean _keepFetching
protected String _lastModified
protected final String _lastModifiedOrig
protected final List<EepGet.StatusListener> _listeners
protected final Log _log
protected volatile boolean _notModified
protected final int _numRetries
protected OutputStream _out
protected final String _outputFile
protected final OutputStream _outputStream
protected Socket _proxy
protected final String _proxyHost
protected InputStream _proxyIn
protected OutputStream _proxyOut
protected final int _proxyPort
protected String _redirectLocation
protected volatile int _redirects
protected String _referrerPolicy
protected volatile int _responseCode
protected String _responseText
protected String _server
protected final boolean _shouldProxy
protected volatile boolean _shouldWriteErrorToOutput
protected String _status
protected String _transferEncoding
protected volatile boolean _transferFailed
protected final String _url
protected String _vary
protected String _xContentTypeOptions
protected String _xframeOptions
protected String _xPoweredBy
protected String _xssProtection
protected static final int CONNECT_TIMEOUT
protected static final int INACTIVITY_TIMEOUT
protected static final int MAX_COMPLETE_FAILS
protected static final String USER_AGENT
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)
outputFile - ignored if outputStream is non-nulloutputStream - takes precedence over outputFilepublic 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)
outputFile - ignored if outputStream is non-nulloutputStream - takes precedence over outputFilepublic EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url)
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag)
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag, String lastModified)
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, String postData)
public EepGet(I2PAppContext ctx, int numRetries, String outputFile, String url)
public EepGet(I2PAppContext ctx, int numRetries, String outputFile, String url, boolean allowCaching)
public EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url)
public EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching)
public void addAuthorization(String userName, String password)
public void addHeader(String name, String value)
public void addStatusListener(EepGet.StatusListener lsnr)
protected void doFetch(SocketTimeout timeout) throws IOException
timeout - may be nullIOExceptionpublic boolean fetch()
public boolean fetch(long fetchHeaderTimeout)
public boolean fetch(long fetchHeaderTimeout,
long totalTimeout,
long inactivityTimeout)
fetchHeaderTimeout - <= 0 for none (proxy will timeout if none, none isn't recommended if no proxy)totalTimeout - <= 0 for default noneinactivityTimeout - <= 0 for default 60 secpublic String getAcceptRanges()
public String getCacheControl()
public String getContentEncoding()
public String getContentLanguage()
public String getContentType()
public String getCookie()
public String getCSP()
public String getEtag()
public String getExpiryDate()
public String getLastModified()
public boolean getNotModified()
public String getReferrerPolicy()
protected String getRequest() throws IOException
IOExceptionpublic String getServer()
public String getStatus()
public int getStatusCode()
public String getStatusText()
public String getTransferEncoding()
public String getVary()
public String getXContentTypeOptions()
public String getXframeOptions()
public String getXPoweredBy()
public String getXSSProtection()
public static void main(String[] args)
public static Map<String,String> parseAuthArgs(String args)
args - non-null, starting after "Digest " or "Basic "protected long readChunkLength()
throws IOException
IOExceptionprotected void readHeaders()
throws IOException
IOExceptionprotected void sendRequest(SocketTimeout timeout) throws IOException
timeout - may be nullIOExceptionprotected void setPostData(String contentType, byte[] data)
IllegalStateException - if already setprotected void setPostData(String contentType, File data)
IllegalStateException - if already setprotected void setPostData(String contentType, String data)
IllegalStateException - if already setpublic void setWriteErrorToOutput()
protected boolean shouldReadBody()
public void stopFetching()