Add support for Content-Disposition response header field#22
Add support for Content-Disposition response header field#22konstruktiv wants to merge 1 commit intoamandasaurus:mainfrom
Conversation
|
That looks good. But rather than the argument being the entire value of the i.e. would this be a more ergonomic and nicer API: cgi::binary_response(200, "application/octet-stream", "filename.bin", vec![1, 2]);If the argument is set, then the header value can be constructed from Is this possible? Desireable? |
|
That is a nicer API, but it would miss the other parts of the Would it be an option to accept both in the same argument? I.e. a filename or the full header string starting with "content-disposition: " in case someone needs it. Using something like this: if let Some(cd) = content_disposition {
const HEADER_NAME: &str = "content-disposition: ";
let arg_cleaned: String = cd.to_lowercase().trim().to_string();
let cd = if arg_cleaned.starts_with(HEADER_NAME) {
arg_cleaned.split(HEADER_NAME).collect::<String>()
} else {
format!("attachment; filename=\"{}\"", cd)
};
response = response.header(http::header::CONTENT_DISPOSITION, cd);
}The same could be done for |
PR to fix #21.