See also browser/external, which requires racket/gui, but can prompt the user for a browser if no browser preference is set.
If escape? is true, then str is escaped (by UTF-8 encoding followed by “%” encoding) to avoid dangerous shell characters: single quotes, double quotes, backquotes, dollar signs, backslashes, non-ASCII characters, and non-graphic characters. Note that escaping does not affect already-encoded characters in str.
On all platforms, external-browser parameter can be set to a
procedure to override the above behavior —
(send-url/file path [ separate-window? #:fragment fragment #:query query]) → void? path : path-string? separate-window? : any/c = #t fragment : (or/c string? false/c) = #f query : (or/c string? false/c) = #f
The path, fragment, and query arguments are all encoded in the same way as a path provided to send-url, which means that already-encoded characters are used as-is.
When send-url/content is called, it scans old generated files (this happens randomly, not on every call) and removes them to avoid cluttering the temporary directory. If the #:delete-at argument is a number, then the temporary file is more eagerly removed after the specified number of seconds; the deletion happens in a thread, so if Racket exits earlier, the deletion will not happen. If the #:delete-at argument is #f, no eager deletion happens, but old temporary files are still deleted as described above.
(send-url/mac "http://www.google.com/" #:browser "Firefox")
This function looks in "com.apple.launchservices.secure.plist" in the user’s home directory for a LSHandlerURLScheme key for either http or https and then, looks for a LSHandlerRoleAll key that is one of a list of known browsers. If it finds such a browser, it uses the AppleScript command tell application ... to open location to send the url to the browser. Otherwise, it uses just open location to send the url to the browser.
(external-browser cmd) → void? cmd : browser-preference?
On Unix, the command that is used depends on the 'external-browser preference. If the preference is unset, send-url uses the first of the browsers from unix-browser-list for which the executable is found. Otherwise, the preference should hold a symbol indicating a known browser (from the unix-browser-list), or it a pair of a prefix and a suffix string that are concatenated around the url string to make up a shell command to run. In addition, the external-browser paremeter can be set to one of these values, and send-url will use it instead of the preference value.
Note that the URL is encoded to make it work inside shell double-quotes: URLs can still hold characters like #, ?, and &, so if the external-browser is set to a pair of prefix/suffix strings, they should use double quotes around the url.