#lang scribble/doc @(require (file "base.ss")) @(define-eval plain-eval (planet untyped/mirrors/plain/plain) web-server/http) @title[#:tag "plain"]{Plain text} Mirrors contains a few procedures and utilities for sending plain text responses: @defmodule[(planet untyped/mirrors/plain/plain)] @defproc[(make-plain-response [#:code code integer? 200] [#:message message (U string? bytes?) #"OK"] [#:seconds seconds integer? (current-seconds)] [#:mime-type mime-type (U string? bytes?) #"text/plain; charset=utf-8"] [#:headers headers (alistof symbol? string?) no-cache-http-headers] [content (listof string?)]) response/full?]{ Keyword wrapper for @scheme[make-response/full] with sensible defaults for most purposes.} @defproc[(make-plain-response/incremental [#:code code integer? 200] [#:message message (U string? bytes?) #"OK"] [#:seconds seconds integer? (current-seconds)] [#:mime-type mime-type (U string? bytes?) #"text/plain; charset=utf-8"] [#:headers headers (alistof symbol? string?) no-cache-http-headers] [content (((listof (U bytes? string?)) -> any) -> any)]) response/incremental?]{ Keyword wrapper for @scheme[make-response/incremental] with sensible defaults for most purposes.} @defproc[(make-redirect-response [#:code code integer? 302] [#:message message (U string? bytes?) #"Moved temporarily"] [#:headers headers (alistof symbol? string?) no-cache-http-headers] [url (U string? url?)]) response/full?]{ Creates a response that redirects the user to the specified @scheme[url]. A @italic{Location} header is constructed from the URL; members of @scheme[headers] of the same name are removed.} @defthing[no-cache-http-headers (listof header?)]{ The default HTTP headers generated by @scheme[make-html-response], @scheme[make-js-response], @scheme[make-plain-response] and others, designed to prevent the browser caching dynamically generated pages: @interaction[ #:eval plain-eval (for-each (lambda (header) (printf "~a: ~a~n" (header-field header) (header-value header))) no-cache-http-headers)]}