package tiny_httpd
Module Tiny_httpd.ResponseSource
Body of a response, either as a simple string, or a stream of bytes, or nothing (for server-sent events).
type t = {code : Response_code.t;headers : Headers.t;(*Headers of the reply. Some will be set by
*)Tiny_httpdautomatically.body : body;(*Body of the response. Can be empty.
*)
}A response to send back to a client.
Make a response from its raw components, with a string body. Use "" to not send a body at all.
Same as make_raw but with a stream body. The body will be sent with the chunked transfer-encoding.
make r turns a result into a response.
make (Ok body)replies with200and the body.make (Error (code,msg))replies with the given error code and message as body.
Same as make but with a string body.
Same as make but with a stream body.
Make the current request fail with the given code and message. Example: fail ~code:404 "oh noes, %s not found" "waldo".
Similar to fail but raises an exception that exits the current handler. This should not be used outside of a (path) handler. Example: fail_raise ~code:404 "oh noes, %s not found" "waldo"; never_executed()
Pretty print the response.