9.9 Miscellaneous Utilities
On this page:
9.9.1 Contracts
port-number?
path-element?
9.9.2 Lists
list-prefix?
9.9.3 URLs
url-replace-path
url-path->string
9.9.4 Paths
explode-path*
path-without-base
directory-part
build-path-unless-absolute
strip-prefix-ups
9.9.5 Exceptions
pretty-print-invalid-xexpr
network-error
exn->string
9.9.6 Strings
lowercase-symbol!
read/ string
write/ string
Version: 4.1

9.9 Miscellaneous Utilities

 (require web-server/private/util)

There are a number of other miscellaneous utilities the Web Server needs. They are provided by "private/util.ss".

9.9.1 Contracts

port-number? : contract?

Equivalent to (between/c 1 65535).

path-element? : contract?

Equivalent to (or/c string? path? (symbols 'up 'same)).

9.9.2 Lists

(list-prefix? l r)  boolean?

  l : list?

  r : list?

True if l is a prefix of r.

9.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.

9.9.4 Paths

(explode-path* p)  (listof path-element?)

  p : path?

Like normalize-path, but does not resolve symlinks.

(path-without-base base p)  (listof path-element?)

  base : path?

  p : path?

Returns, as a list, the portion of p after base, assuming base is a prefix of p.

(directory-part p)  path?

  p : path?

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.

(strip-prefix-ups p)  (listof path-element?)

  p : (listof path-element?)

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

9.9.5 Exceptions

(pretty-print-invalid-xexpr exn v)  void

  exn : exn:invalid-xexpr?

  v : any/c

Prints v as if it were almost an X-expression highlighting the error according to exn.

(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.

9.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.