Liking cljdoc? Tell your friends :D

urlocal.api

The public API of the urlocal library.

The public API of the urlocal library.
raw docstring

input-streamclj

(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 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.

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.
sourceraw docstring

remove-cache-entry!clj

(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.
sourceraw docstring

reset-cache!clj

(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.
sourceraw docstring

set-cache-check-interval-secs!clj

(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).
sourceraw docstring

set-cache-name!clj

(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:

  • 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.

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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close