Skip to content

Commit

Permalink
Add "Access-Control-Request-Private-Network" to Vary
Browse files Browse the repository at this point in the history
This should have been part of rs#127.
  • Loading branch information
cvermilion committed Oct 3, 2022
1 parent da52b07 commit e61db5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ func (c *Cors) handlePreflight(w http.ResponseWriter, r *http.Request) {
headers.Add("Vary", "Origin")
headers.Add("Vary", "Access-Control-Request-Method")
headers.Add("Vary", "Access-Control-Request-Headers")
if c.allowPrivateNetwork {
headers.Add("Vary", "Access-Control-Request-Private-Network")
}

if origin == "" {
c.logf(" Preflight aborted: empty origin")
Expand Down
2 changes: 1 addition & 1 deletion cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func TestSpec(t *testing.T) {
"Access-Control-Request-Private-Network": "true",
},
map[string]string{
"Vary": "Origin, Access-Control-Request-Method, Access-Control-Request-Headers",
"Vary": "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
"Access-Control-Allow-Origin": "http://foobar.com",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Private-Network": "true",
Expand Down

0 comments on commit e61db5e

Please sign in to comment.