3.6.9 Miscellaneous Utilities
On this page:
3.6.9.1 Contracts
port-number?
path-element?
3.6.9.2 Lists
list-prefix?
3.6.9.3 URLs
url-replace-path
url-path->string
3.6.9.4 Paths
explode-path*
path-without-base
directory-part
build-path-unless-absolute
strip-prefix-ups
3.6.9.5 Exceptions
pretty-print-invalid-xexpr
network-error
exn->string
3.6.9.6 Strings
lowercase-symbol!
read/ string
write/ string
3.6.9.7 Bytes
read/ bytes
write/ bytes
Version: 4.1.3
3.6.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".

3.6.9.1 Contracts

port-number? : contract?

Equivalent to (between/c 1 65535).

path-element? : contract?

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

3.6.9.2 Lists

(list-prefix? l r)  boolean?
  l : list?
  r : list?

True if l is a prefix of r.

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

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

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

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

3.6.9.7 Bytes

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