code: func Handshake(req *http.Request, w http.ResponseWriter, serverProtocols []string) (string, error) {
  	clientProtocols := req.Header[http.CanonicalHeaderKey(HeaderProtocolVersion)]
  	if len(clientProtocols) == 0 {
  		// Kube 1.0 clients didn't support subprotocol negotiation.
  		// TODO require clientProtocols once Kube 1.0 is no longer supported
  		return "", nil
  	}
  
  	if len(serverProtocols) == 0 {
  		// Kube 1.0 servers didn't support subprotocol negotiation. This is mainly for testing.
  		// TODO require serverProtocols once Kube 1.0 is no longer supported
  		return "", nil
  	}
  
  	negotiatedProtocol := negotiateProtocol(clientProtocols, serverProtocols)
  	if len(negotiatedProtocol) == 0 {
  		for i := range serverProtocols {
  			w.Header().Add(HeaderAcceptedProtocolVersions, serverProtocols[i])
  		}
  		err := fmt.Errorf("unable to upgrade: unable to negotiate protocol: client supports %v, server accepts %v", clientProtocols, serverProtocols)
  		http.Error(w, err.Error(), http.StatusForbidden)
  		return "", err
  	}
  
  	w.Header().Add(HeaderProtocolVersion, negotiatedProtocol)
  	return negotiatedProtocol, nil
  }
docs: // Handshake performs a subprotocol negotiation. If the client did request a
  // subprotocol, Handshake will select the first common value found in
  // serverProtocols. If a match is found, Handshake adds a response header
  // indicating the chosen subprotocol. If no match is found, HTTP forbidden is
  // returned, along with a response header containing the list of protocols the
  // server can accept.