MCPcopy
hub / github.com/gorilla/websocket / checkSameOrigin

Function checkSameOrigin

server.go:89–99  ·  view source on GitHub ↗

checkSameOrigin returns true if the origin is not set or is equal to the request host.

(r *http.Request)

Source from the content-addressed store, hash-verified

87
88// checkSameOrigin returns true if the origin is not set or is equal to the request host.
89func checkSameOrigin(r *http.Request) bool {
90 origin := r.Header["Origin"]
91 if len(origin) == 0 {
92 return true
93 }
94 u, err := url.Parse(origin[0])
95 if err != nil {
96 return false
97 }
98 return equalASCIIFold(u.Host, r.Host)
99}
100
101func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
102 if u.Subprotocols != nil {

Callers 1

TestCheckSameOriginFunction · 0.85

Calls 1

equalASCIIFoldFunction · 0.85

Tested by 1

TestCheckSameOriginFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…