1 XML
2 Javascript
3 CSV
4 Plain text
On this page:
make-plain-response
make-plain-response/ incremental
make-redirect-response
no-cache-http-headers
Version: 4.0.1

 

4 Plain text

Mirrors contains a few procedures and utilities for sending plain text responses:

 (require (planet untyped/mirrors/plain/plain))

(make-plain-response

 [

#:code code

 

 

 

 

 

 

#:message message

 

 

 

 

 

 

#:seconds seconds

 

 

 

 

 

 

#:mime-type mime-type

 

 

 

 

 

 

#:headers headers]

 

 

 

 

 

 

content)

 

 

response

  code : integer? = 200

  message : string? = "OK"

  seconds : integer = (current-seconds)

  mime-type : (U string? bytes?) = #"text/plain; charset=utf-8"

  headers : (alistof symbol? string?) = no-cache-http-headers

  content : (listof string?)

A keyword wrapper for make-response/full with sensible defaults for most purposes.

(make-plain-response/incremental

 [

#:code code

 

 

 

#:message message

 

 

 

#:seconds seconds

 

 

 

#:mime-type mime-type

 

 

 

#:headers headers]

 

 

 

content)

 

  response

  code : integer? = 200

  message : string? = "OK"

  seconds : integer? = (current-seconds)

  mime-type : (U string? bytes?) = #"text/plain; charset=utf-8"

  headers : (alistof symbol? string?) = no-cache-http-headers

  content : (((listof (U bytes? string?)) -> any) -> any)

A keyword wrapper for make-response/incremental with sensible defaults for most purposes.

(make-redirect-response

 [

#:code code

 

 

 

 

 

 

#:message message

 

 

 

 

 

 

#:headers headers]

 

 

 

 

 

 

url)

 

 

response

  code : integer? = 302

  message : string? = "Moved temporarily"

  headers : (alistof symbol? string?) = no-cache-http-headers

  url : (U string? url?)

Creates a response that redirects the user to the specified url. A Location header is constructed from the URL; members of headers of the same name are removed.

no-cache-http-headers : (listof header?)

The default HTTP headers generated by make-html-response, make-js-response, make-plain-response and others, designed to prevent the browser caching dynamically generated pages:

  > (for-each (lambda (header)

                (printf "~a: ~a~n"

                        (header-field header)

                        (header-value header)))

              no-cache-http-headers)

  Cache-Control: no-cache, no-store

  Pragma: no-cache

  Expires: Mon, 26 Jul 1997 05:00:00 GMT