code: func serveHijack(w http.ResponseWriter, targetConn net.Conn) (int, error) {
  	hijacker, ok := w.(http.Hijacker)
  	if !ok {
  		return http.StatusInternalServerError, errors.New("ResponseWriter does not implement Hijacker")
  	}
  	clientConn, bufReader, err := hijacker.Hijack()
  	if err != nil {
  		return http.StatusInternalServerError, errors.New("failed to hijack: " + err.Error())
  	}
  	defer clientConn.Close()
  	// bufReader may contain unprocessed buffered data from the client.
  	if bufReader != nil {
  		// snippet borrowed from `proxy` plugin
  		if n := bufReader.Reader.Buffered(); n > 0 {
  			rbuf, err := bufReader.Reader.Peek(n)
  			if err != nil {
  				return http.StatusBadGateway, err
  			}
  			targetConn.Write(rbuf)
  		}
  	}
  	// Since we hijacked the connection, we lost the ability to write and flush headers via w.
  	// Let's handcraft the response and send it manually.
  	res := &http.Response{StatusCode: http.StatusOK,
  		Proto:      "HTTP/1.1",
  		ProtoMajor: 1,
  		ProtoMinor: 1,
  		Header:     make(http.Header),
  	}
  	res.Header.Set("Server", "Caddy")
  
  	err = res.Write(clientConn)
  	if err != nil {
  		return http.StatusInternalServerError, errors.New("failed to send response to client: " + err.Error())
  	}
  
  	return 0, dualStream(targetConn, clientConn, clientConn, targetConn)
  }
docs: // Hijacks the connection from ResponseWriter, writes the response and proxies data between targetConn
  // and hijacked connection.