this.tracer = tracer;
}
+ /**
+ * The {@link Cache} to use for all access (can be NULL).
+ *
+ * @return the cache
+ */
+ public Cache getCache() {
+ return cache;
+ }
+
+ /**
+ * The {@link Cache} to use for all access (can be NULL).
+ *
+ * @param cache
+ * the new cache
+ */
+ public void setCache(Cache cache) {
+ this.cache = cache;
+ }
+
/**
* Clear all the cookies currently in the jar.
* <p>
* @param url
* the {@link URL} to open
* @param originalUrl
- * the original {@link URL} before any redirection occurs
+ * the original {@link URL} before any redirection occurs, which
+ * is also used for the cache ID if needed (so we can retrieve
+ * the content with this URL if needed)
+ * @param currentReferer
+ * the current referer, for websites that needs this info
+ * @param cookiesValues
+ * the cookies
* @param postParams
* the POST parameters
* @param getParams
* @throws IOException
* in case of I/O error
*/
- private InputStream open(URL url, final URL originalUrl,
- URL currentReferer, Map<String, String> cookiesValues,
- Map<String, String> postParams, Map<String, String> getParams,
- String oauth, boolean stable) throws IOException {
+ public InputStream open(URL url, final URL originalUrl, URL currentReferer,
+ Map<String, String> cookiesValues, Map<String, String> postParams,
+ Map<String, String> getParams, String oauth, boolean stable)
+ throws IOException {
tracer.trace("Request: " + url);
if (cache != null) {
- InputStream in = cache.load(url, false, stable);
+ InputStream in = cache.load(originalUrl, false, stable);
if (in != null) {
- tracer.trace("Take from cache: " + url);
+ tracer.trace("Use the cache: " + url);
+ tracer.trace("Original URL : " + originalUrl);
return in;
}
}
builder.append(';');
}
- // TODO: check if format is ok
builder.append(cookie.toString());
}