The public API of the urlocal library.
The public API of the urlocal library.
(input-stream url)
(input-stream url
{:keys [connect-timeout read-timeout follow-redirects?
request-headers return-cached-content-on-exception?]
:or {connect-timeout 1000
read-timeout 1000
follow-redirects? false
request-headers {"User-Agent" "com.github.pmonks/urlocal"}
return-cached-content-on-exception? true}
:as opts})
Returns an InputStream for the content retrieved from url (a String, java.net.URL or java.net.URI) and caching it, or nil if url is nil or unsupported (i.e. is not an http(s) URL).
The options map provides these tunables, all of them optional:
:connect-timeout
(int, default=1000): the number of milliseconds to wait
when establishing the socket connection before timing out:read-timeout
(int, default=1000): the number of milliseconds to wait when
reading content over the socket before timing out:follows-redirects?
(boolean, default=false): whether to follow a single
redirect (HTTP status codes 301, 302) if the server issues one (more than
one redirect will throw an exception):request-headers
(map with string keys and values): a map of request
headers to send along with the requestreturn-cached-content-on-exception?
(boolean, default=true): whether
(potentially stale) cached content should be returned if it's available, and
an exception occurs while checking for stalenessThrows on IO errors.
Returns an InputStream for the content retrieved from url (a String, java.net.URL or java.net.URI) and caching it, or nil if url is nil or unsupported (i.e. is not an http(s) URL). The options map provides these tunables, all of them optional: * `:connect-timeout` (int, default=1000): the number of milliseconds to wait when establishing the socket connection before timing out * `:read-timeout` (int, default=1000): the number of milliseconds to wait when reading content over the socket before timing out * `:follows-redirects?` (boolean, default=false): whether to follow a single redirect (HTTP status codes 301, 302) if the server issues one (more than one redirect will throw an exception) * `:request-headers` (map with string keys and values): a map of request headers to send along with the request * `return-cached-content-on-exception?` (boolean, default=true): whether (potentially stale) cached content should be returned if it's available, and an exception occurs while checking for staleness Throws on IO errors.
(remove-cache-entry! url)
Removes the cache entry for a single URL, if it exists. Returns nil.
Throws on IO errors.
Removes the cache entry for a single URL, if it exists. Returns nil. Throws on IO errors.
(reset-cache!)
Resets (i.e. deletes) the local cache, returning nil.
Throws on IO errors.
Resets (i.e. deletes) the local cache, returning nil. Throws on IO errors.
(set-cache-check-interval-secs! cache-check-interval-secs)
Sets the cache check interval, in seconds. Default is 86,400 (24 hours).
Sets the cache check interval, in seconds. Default is 86,400 (24 hours).
(set-cache-name! name)
Sets the name of the cache (which ends up being part of the cache directory's name), and returns nil. Default is 'urlocal'.
Notes:
reset-cache!
prior to setting a new name.Throws on IO errors.
Sets the name of the cache (which ends up being part of the cache directory's name), and returns nil. Default is 'urlocal'. Notes: * name must not be blank. * the new cache may not be empty if it was previously populated. * setting a new name after a previously named cache has already been populated will 'orphan' the prior cache. To avoid this, you should call `reset-cache!` prior to setting a new name. Throws on IO errors.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close