5.9 Miscellaneous Utilities
On this page:
5.9.1 Contracts
non-empty-string/ c
port-number?
path-element?
5.9.2 Lists
list-prefix?
5.9.3 URLs
url-replace-path
url-path->string
5.9.4 Paths
explode-path*
path-without-base
directory-part
build-path-unless-absolute
strip-prefix-ups
5.9.5 Exceptions
network-error
exn->string
5.9.6 Strings
lowercase-symbol!
read/ string
write/ string
5.9.7 Bytes
bytes-ci=?
read/ bytes
write/ bytes
Version: 4.2.1

5.9 Miscellaneous Utilities

 (require web-server/private/util)

There are a number of other miscellaneous utilities the Web Server needs. They are provided by this module.

5.9.1 Contracts

Contract for non-empty strings.
Equivalent to (between/c 1 65535).
Equivalent to (or/c path-string? (symbols 'up 'same)).

5.9.2 Lists

(list-prefix? l r)  boolean?
  l : list?
  r : list?
True if l is a prefix of r.

5.9.3 URLs

(url-replace-path proc u)  url?
  proc : ((listof path/param?) . -> . (listof path/param?))
  u : url?
Replaces the URL path of u with proc of the former path.

(url-path->string url-path)  string?
  url-path : (listof path/param?)
Formats url-path as a string with "/" as a delimiter and no params.

5.9.4 Paths

Like normalize-path, but does not resolve symlinks.

(path-without-base base p)  (listof path-element?)
  base : path-string?
  p : path-string?
Returns, as a list, the portion of p after base, assuming base is a prefix of p.

(directory-part p)  path?
  p : path-string?
Returns the directory part of p, returning (current-directory) if it is relative.

(build-path-unless-absolute base p)  path?
  base : path-string?
  p : path-string?
Prepends base to p, unless p is absolute.

Removes all the prefix ".."s from p.

5.9.5 Exceptions

(network-error s fmt v ...)  void
  s : symbol?
  fmt : string?
  v : any/c
Like error, but throws a exn:fail:network.

(exn->string exn)  string?
  exn : (or/c exn? any/c)
Formats exn with (error-display-handler) as a string.

5.9.6 Strings

(lowercase-symbol! sb)  symbol?
  sb : (or/c string? bytes?)
Returns sb as a lowercase symbol.

(read/string s)  serializable?
  s : string?
reads a value from s and returns it.

(write/string v)  string?
  v : serializable?
writes v to a string and returns it.

5.9.7 Bytes

(bytes-ci=? b1 b2)  boolean?
  b1 : bytes?
  b2 : bytes?
Compares two bytes case insensitively.

(read/bytes b)  serializable?
  b : bytes?
reads a value from b and returns it.

(write/bytes v)  bytes?
  v : serializable?
writes v to a bytes and returns it.