11 Utility functions
11.1 fetch-uri
(fetch-uri uri) → string |
uri : string |
Any response to the URL with a MIME type string containing “xml” is treated as an XML document and labelled with the ".xml" extension.
JPEG and PNG image files are downloaded and given a file path with their respective common file extensions.
Gets the extension ".txt". Scheme files also use the text/plain MIME type. So you can load ".scm" files using -(load (fetch-uri "http://somewhere.com/path/lib.scm"))
11.1.1 Exceptions with fetch-uri
Whenever you access the network, you should guard yourself against exceptional conditions such as connection failures, transfer interruptions, etc. The fetch-uri function raises a few exceptions to let you know about these conditions so you can respond to them. When these exceptions occur, you can choose to abort the operation or continue with, say, a default file. For details about raising and handling muSE exceptions and about the resume continuation, refer to the documentation on the muSE project page.
Indicates a fundamental problem with connecting to the internet. You can resume when this exception occurs by choosing to use a fixed local file path instead of the downloaded URI. You can resume like this -(resume "somewhere\blah.jpg")
Indicates that the URI is either badly formatted or is referring to an invalid resource. In this case, you can resume by either using a default URI that is known to work, or a fixed local file, using the resume function.
Indicates that the URI is not a http URI or is of a type that cannot be supported for some reason. In this case, you’re allowed to resume by replacing the URI with a default file.
Indicates a problem downloading the URI and storing it in the cache. In this case, you’re allowed to replace it with a local file.