This namespace is not part of the public API of urlocal and may change without notice.
This namespace is not part of the public API of urlocal and may change without notice.
(base64-encode x)
Returns a BASE64 encoded representation (a String) of the UTF-8 String representation of x, or nil if x is nil
Returns a BASE64 encoded representation (a String) of the UTF-8 String representation of x, or nil if x is nil
(cache-hit! url metadata-file metadata)
Handles a cache hit, by updating the :last-checked-at metadata. Assumes that the cache is already populated with the given URL.
Throws on IO errors.
Handles a cache hit, by updating the :last-checked-at metadata. Assumes that the cache is already populated with the given URL. Throws on IO errors.
(cache-key->cache-file cache-key)
(cache-key->cache-file cache-key extension)
Returns a File for the given cache-key (a String), optionally with the given extension. Return nil if cache-key is blank.
Returns a File for the given cache-key (a String), optionally with the given extension. Return nil if cache-key is blank.
(cache-miss! source opts)
(cache-miss! source already-redirected? opts)
Handles a cache miss, by caching content locally and capturing metadata from the response for the purposes of cache management.
source may be:
Throws on IO errors or unexpected HTTP status code responses.
Handles a cache miss, by caching content locally and capturing metadata from the response for the purposes of cache management. source may be: * a URL, in which case an HTTP GET request is made * a HttpURLConnection, in which case it is assumed to already be connected Throws on IO errors or unexpected HTTP status code responses.
(check-cache! url
{:keys [request-headers return-cached-content-on-exception?]
:as opts})
Handles a potential cache hit, by determining whether the cached content needs to be checked for staleness via an ETag request, or whether it can simply be served directly. Assumes that the cache is already populated with the given URL.
Throws on IO errors or unexpected HTTP status code responses.
Handles a potential cache hit, by determining whether the cached content needs to be checked for staleness via an ETag request, or whether it can simply be served directly. Assumes that the cache is already populated with the given URL. Throws on IO errors or unexpected HTTP status code responses.
(http-get url)
(http-get url
{:keys [connect-timeout read-timeout follow-redirects?
request-headers]
:or {connect-timeout 1000
read-timeout 1000
follow-redirects? false
request-headers {"User-Agent" "com.github.pmonks/urlocal"}}})
Perform an HTTP GET request for the given URL, using the given options, returning an HTTPUrlConnection object.
Throws on IO errors.
Perform an HTTP GET request for the given URL, using the given options, returning an HTTPUrlConnection object. Throws on IO errors.
(prep-cache! url opts)
Ensures the cache is populated for the given url.
Ensures the cache is populated for the given url.
(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.
(seconds-since inst)
Returns how many seconds have passed since inst (a Date or Temporal), or Long/MAX_VALUE if inst is nil.
Returns how many seconds have passed since inst (a Date or Temporal), or Long/MAX_VALUE if inst is nil.
(url->content-file url)
Returns a content file for the given url, or nil if the url is nil.
Returns a content file for the given url, or nil if the url is nil.
(url->metadata-file url)
Returns a metadata file for the given url, or nil if the url is nil.
Returns a metadata file for the given url, or nil if the url is nil.
(write-metadata! conn)
Writes out a metadata file for the given open connection.
Note: does nothing if the connection did not return an ETag - this ensures that future requests to the same URL will always be treated as a cache miss.
Writes out a metadata file for the given open connection. Note: does nothing if the connection did not return an ETag - this ensures that future requests to the same URL will always be treated as a cache miss.
(write-metadata-file! f m)
Writes the metadata m to the file f, overwriting it if it already exists.
Writes the metadata m to the file f, overwriting it if it already exists.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close