Function binary_response

Source
pub fn binary_response<'a, T>(
    status_code: T,
    content_type: impl Into<Option<&'a str>>,
    body: Vec<u8>,
) -> Response
Expand description

Sends blob with that status code, and optional content type, None for no Content-Type header to be set.

No Content-Type header:

rust_cgi::binary_response(200, None, vec![1, 2]);

Send an image:

rust_cgi::binary_response(200, "image/png", vec![1, 2]);

Send a generic binary blob:

rust_cgi::binary_response(200, "application/octet-stream", vec![1, 2]);