Return a stream to read given URL. Returned stream is suitable only for reading, and the initial position is always at the beginning. Overloaded version also returns a MIME type (or '' if unknown).
All errors are reported by raising exceptions.
A local file URL is always supported, without using any networking library. URL without any protocol is always treated like a local filename (absolute or relative to current dir), so this function can be a drop-in replacement for normal file reading. The MIME type for local files is guessed based on their extension.
A data URI scheme (http://en.wikipedia.org/wiki/Data_URI_scheme) is also always supported. The MIME type for such content is specified explicitly in URI. TODO: right now, soGzip is ignored for data URIs, we never filter them through gunzip.
It also automatically supports protocols to embed script contents: ecmascript, javascript (see VRML and X3D specifications), castlescript, kambiscript (see http://castle-engine.sourceforge.net/castle_script.php), compiled (http://castle-engine.sourceforge.net/x3d_extensions.php#section_ext_script_compiled). The MIME type for these is implied by the protocol (like "application/javascript" for ecmascript/javascript), and the returned stream simply contains script code.
Set EnableNetwork to True to have also support for network protocols. Right now this means only http, handled by FpHttpClient. The MIME type for such content is usually reported by the http server (but if the server doesn't report MIME type, we still try to guess it, looking at URL using URIMimeType).
On Android, URLs that indicate assets (files packaged inside .apk) are also supported, as assets:/my_file.png .
|