racket/collects/web-server/private/response-structs.ss
Eli Barzilay 7d50e61c7f * Newlines at EOFs
* Another big chunk of v4-require-isms
* Allow `#lang framework/keybinding-lang' for keybinding files
* Move hierlist sources into "mrlib/hierlist", leave stub behind

svn: r10689
2008-07-09 07:18:06 +00:00

53 lines
1.6 KiB
Scheme

#lang scheme/base
(require mzlib/contract
xml/xml
"request-structs.ss")
(define TEXT/HTML-MIME-TYPE #"text/html; charset=utf-8")
(define-struct response/basic (code message seconds mime headers)
#:mutable)
(define-struct (response/full response/basic) (body)
#:mutable)
(define-struct (response/incremental response/basic) (generator)
#:mutable)
; response = (cons string (listof string)), where the first string is a mime-type
; | x-expression
; | response/basic
;; response?: any -> boolean
;; Determine if an object is a response
(define (response? x)
(or (response/basic? x)
(and (pair? x) (andmap (lambda (e)
(or (string? e)
(bytes? e)))
x))
(xexpr? x)))
(provide/contract
[struct response/basic
([code number?]
[message string?]
[seconds number?]
[mime bytes?]
[headers (listof header?)])]
[struct (response/full response/basic)
([code number?]
[message string?]
[seconds number?]
[mime bytes?]
[headers (listof header?)]
[body (listof (or/c string?
bytes?))])]
[struct (response/incremental response/basic)
([code number?]
[message string?]
[seconds number?]
[mime bytes?]
[headers (listof header?)]
[generator ((() (listof (or/c bytes? string?)) . ->* . any) . -> . any)])]
[response? (any/c . -> . boolean?)]
[TEXT/HTML-MIME-TYPE bytes?])