Skip to main content

bytes

Function bytes 

Source
pub fn bytes(
    content_type: impl Into<Cow<'static, str>>,
    data: impl Into<Vec<u8>>,
) -> ReplyData
Expand description

Build a ReplyData::Bytes with an explicit Content-Type. The content-type is required: there is no honest default for arbitrary bytes, and application/octet-stream masquerading as one tends to cause more bugs than it fixes (browsers guess; downstream HTTP caches mis-cache). Pass the right media type at the call site.

reply::bytes("application/zip", zip_payload)
reply::bytes("image/png", png_payload)