public class URLFetcher extends Object
Constructor and Description |
---|
URLFetcher() |
Modifier and Type | Method and Description |
---|---|
WebContent |
getWebContentFromUrl(URL url,
long fileSizeLimit,
int connectionTimeoutMillis)
Fetches the specified url and returns the content and ttl.
|
WebContent |
getWebContentFromUrlWithRetry(URL url,
long fileSizeLimit,
int connectionTimeoutMillis,
int backoffMillis,
int retry)
Fetches the specified url and returns the content and ttl.
|
static String |
inputStreamToString(InputStream inputStream,
int length,
long sizeLimit)
Visible for testing.
|
public WebContent getWebContentFromUrlWithRetry(URL url, long fileSizeLimit, int connectionTimeoutMillis, int backoffMillis, int retry) throws AssociationServiceException, IOException, InterruptedException
Retry retry
times if the connection failed or timed out for any reason.
HTTP error code (e.g. 404/500) won't be retried.
IOException
- if it can't retrieve the content due to a network problem.AssociationServiceException
- if the URL scheme is not http or https or the content
length exceeds {code fileSizeLimit}.InterruptedException
public WebContent getWebContentFromUrl(URL url, long fileSizeLimit, int connectionTimeoutMillis) throws AssociationServiceException, IOException
IOException
- if it can't retrieve the content due to a network problem.AssociationServiceException
- if the URL scheme is not http or https or the content
length exceeds {code fileSizeLimit}.public static String inputStreamToString(InputStream inputStream, int length, long sizeLimit) throws IOException, AssociationServiceException