Skip to main content

tower_helmet/header/
x_download_options.rs

1use http::header::{HeaderName, InvalidHeaderValue};
2use http::HeaderValue;
3
4use crate::IntoHeader;
5
6/// `XDownloadOptions` sets the `X-Download-Options` header, which is specific to Internet Explorer
7/// 8. It forces potentially-unsafe downloads to be saved, mitigating execution of HTML in your
8/// site's context. For more, see [this old post on MSDN](https://docs.microsoft.com/en-us/archive/blogs/ie/ie8-security-part-v-comprehensive-protection).
9pub struct XDownloadOptions;
10
11impl Default for XDownloadOptions {
12    fn default() -> Self {
13        XDownloadOptions
14    }
15}
16
17impl IntoHeader for XDownloadOptions {
18    fn header_name(&self) -> HeaderName {
19        HeaderName::from_static("x-download-options")
20    }
21
22    fn header_value(&self) -> Result<HeaderValue, InvalidHeaderValue> {
23        HeaderValue::from_str("noopen")
24    }
25}