1 Running the Web Server
2 Scheme Servlets
3 Web Language Servlets
4 Configuration
5 Dispatchers
6 Web Config Unit
7 Web Server Unit
8 Continuation Managers
9 Internal
10 Troubleshooting
11 Acknowledgements
Index
On this page:
response/ basic
response/ full
response/ incremental
response?
TEXT/ HTML-MIME-TYPE
Version: 4.0.2

 

2.5 HTTP Responses

 (require web-server/private/response-structs)

"private/response-structs.ss" provides structures and functions related to HTTP responses.

(struct

 

response/basic

 

(code message seconds mime headers))

  code : number?

  message : string?

  seconds : number?

  mime : bytes?

  headers : (listof header?)

A basic HTTP response containing no body. code is the response code, message the message, seconds the generation time, mime the MIME type of the file, and extras are the extra headers, in addition to those produced by the server.

(struct

 

(response/full response/basic)

 

(body))

  body : (listof (or/c string? bytes?))

As with response/basic, except with body as the response body.

(struct

 

(response/incremental response/basic)

 

(generator))

  generator : ((() (listof (or/c bytes? string?)) . ->* . any) . -> . any)

As with response/basic, except with generator as a function that is called to generate the response body, by being given an output-response function that outputs the content it is called with.

(response? v)  boolean?

  v : any/c

Checks if v is a valid response. A response is either:

TEXT/HTML-MIME-TYPE : bytes?

Equivalent to #"text/html; charset=utf-8".

Warning:If you include a Content-Length header in a response that is inaccurate, there WILL be an error in transmission that the server will not catch.