Fetch¶
fetch
fetches a Resource from an URL and outputs its content. You can therefore use this similarly to curl or httpie or wget. (If you want to see the Media Type, use info detect
.)
This is different from get
, which shows Things given an _IRI.
(However the --load
option of get
internally does a fetch
, and supports the same schemes.)
Enola supports the URI schemes which are documented below.
These are supported everywhere; including in fetch
, --load
, and elsewhere.
Schemes¶
HTTP¶
This will fetch https://www.vorburger.ch/hello.md: (Note how for security reasons we have to explicitly permit it.)
$ ./enola fetch --http-scheme https://www.vorburger.ch/hello.md
# hello, world
Enola locally caches HTTP responses on the filesystem.
Files¶
We can do cat
-like equivalent of local files using the file:
scheme:
$ echo "hello" >/tmp/hi.txt && ./enola fetch file:///tmp/hi.txt
hello
We can omit the file:
scheme and use absolute or relative paths,
because (in the CLI) the current working directory is implicitly the base URI
used to resolve URI references:
$ ./enola fetch /tmp/hi.txt
hello
Classpath¶
$ ./enola fetch classpath:/VERSION
be6c75c
Data¶
Enola supports (RFC 2397) data:
URLs:
$ ./enola fetch "data:application/json;charset=UTF-8,%7B%22key%22%3A+%22value%22%7D"
{"key": "value"}
File Descriptor¶
fd:
is a (non-standard) URL scheme in Enola for reading from or writing to file descriptors, for:
The Media Type of this special resource will be application/octet-stream
(not application/binary
),
unless there is a ?mediaType=
parameter.
The Charset will be the default of the JVM,
unless there is (checked first) a ?charset=
parameter (e.g. fd:0?charset=UTF-16BE
),
or the ?mediaType=
parameter includes a charset (e.g. fd:1?mediaType=application/yaml;charset=utf-16be
).
Empty¶
empty:
is another (non-standard) URL scheme in Enola for “no content” (as an alternative to data:,
):
$ ./enola fetch empty:/
Exec (TODO)¶
We plan to support an exec:
scheme, whose content will be the resulting of running the given command,
similar to e.g. 🐪 Camel’s or (vaguely) Web Browsers’
javascript:
.
Parameters¶
Enola considers certain generic query parameters in URLs it fetches.
These work with most but not all schemes (e.g. data:
does not permit query parameters).
Media Type¶
Adding e.g. ?mediaType=application/json
overrides the Media Type
which e.g. a server provided in e.g. a HTTP header,
or that was determined from a file extension.
Charset¶
Adding e.g. ?charset=iso-8859-1
overrides (and takes precedence over)
the Charset from the Media Type (if any) or any HTTP header like mechanisms.
Integrity (TODO)¶
We plan
to support ?integrity=...
to verify resource integrity via a [cryptographic digest (“hash”)])(https://docs.ipfs.tech/concepts/hashing/)
using a Multiformats’s Multibase encoded Multihash.
This is similar e.g. to HTML’s Subresource Integrity (SRI).