-
Notifications
You must be signed in to change notification settings - Fork 3
/
x-permitted-cross-domain-policies.go
34 lines (27 loc) · 1.33 KB
/
x-permitted-cross-domain-policies.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
29
30
31
32
33
34
package helmet
import "net/http"
// HeaderXPermittedCrossDomainPolicies is the X-Permitted-Cross-Domain-Policies HTTP security header.
const HeaderXPermittedCrossDomainPolicies = "X-Permitted-Cross-Domain-Policies"
// X-Permitted-Cross-Domain-Policies options.
const (
PermittedCrossDomainPoliciesNone XPermittedCrossDomainPolicies = "none"
PermittedCrossDomainPoliciesMasterOnly XPermittedCrossDomainPolicies = "master-only"
PermittedCrossDomainPoliciesByContentType XPermittedCrossDomainPolicies = "by-content-type"
PermittedCrossDomainPoliciesByFTPFilename XPermittedCrossDomainPolicies = "by-ftp-filename"
PermittedCrossDomainPoliciesAll XPermittedCrossDomainPolicies = "all"
)
// XPermittedCrossDomainPolicies represents the X-Permitted-Cross-Domain-Policies HTTP security header.
type XPermittedCrossDomainPolicies string
func (cdp XPermittedCrossDomainPolicies) String() string {
return string(cdp)
}
// Empty returns whether the X-Permitted-Cross-Domain-Policies is empty.
func (cdp XPermittedCrossDomainPolicies) Empty() bool {
return cdp.String() == ""
}
// Header adds the X-DNS-Prefetch-Control HTTP security header to the given http.ResponseWriter.
func (cdp XPermittedCrossDomainPolicies) Header(w http.ResponseWriter) {
if !cdp.Empty() {
w.Header().Set(HeaderXPermittedCrossDomainPolicies, cdp.String())
}
}