-
Notifications
You must be signed in to change notification settings - Fork 3
/
x-download-options.go
28 lines (21 loc) · 825 Bytes
/
x-download-options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package helmet
import "net/http"
// HeaderXDownloadOptions is the X-Download-Options HTTP header.
const HeaderXDownloadOptions = "X-Download-Options"
// XDownloadOptionsNoOpen represents the X-Download-Options No Open option.
const XDownloadOptionsNoOpen XDownloadOptions = "noopen"
// XDownloadOptions represents the X-Download-Options HTTP security header.
type XDownloadOptions string
func (xdo XDownloadOptions) String() string {
return string(xdo)
}
// Empty returns whether the X-Download-Options is empty.
func (xdo XDownloadOptions) Empty() bool {
return xdo.String() == ""
}
// Header adds the X-Download-Options HTTP security header to the given http.ResponseWriter.
func (xdo XDownloadOptions) Header(w http.ResponseWriter) {
if !xdo.Empty() {
w.Header().Set(HeaderXDownloadOptions, xdo.String())
}
}