(w http.ResponseWriter, r *http.Request, status int, reason string)
| 75 | } |
| 76 | |
| 77 | func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) { |
| 78 | err := HandshakeError{reason} |
| 79 | if u.Error != nil { |
| 80 | u.Error(w, r, status, err) |
| 81 | } else { |
| 82 | w.Header().Set("Sec-Websocket-Version", "13") |
| 83 | http.Error(w, http.StatusText(status), status) |
| 84 | } |
| 85 | return nil, err |
| 86 | } |
| 87 | |
| 88 | // checkSameOrigin returns true if the origin is not set or is equal to the request host. |
| 89 | func checkSameOrigin(r *http.Request) bool { |