docs: def _get_handshake_headers(self, upgrade):
          """ Do an HTTP upgrade handshake with the server.
  
          Websockets upgrade from HTTP rather than TCP largely because it was
          assumed that servers which provide websockets will always be talking to
          a browser. Maybe a reasonable assumption once upon a time...
  
          The headers here will go a little further and also agree the
          WAMP websocket JSON subprotocols.
  
          """
          headers = []
          # https://tools.ietf.org/html/rfc6455
          headers.append("GET {} HTTP/1.1".format(self.websocket_location))
          headers.append("Host: {}:{}".format(self.host, self.port))
          headers.append("Upgrade: websocket")
          headers.append("Connection: Upgrade")
          # Sec-WebSocket-Key header containing base64-encoded random bytes,
          # and the server replies with a hash of the key in the
          # Sec-WebSocket-Accept header. This is intended to prevent a caching
          # proxy from re-sending a previous WebSocket conversation and does not
          # provide any authentication, privacy or integrity
          headers.append("Sec-WebSocket-Key: {}".format(self.key))
          headers.append("Origin: ws://{}:{}".format(self.host, self.port))
          headers.append("Sec-WebSocket-Version: {}".format(WEBSOCKET_VERSION))
  
          if upgrade:
              headers.append("Sec-WebSocket-Protocol: {}".format(
                  WEBSOCKET_SUBPROTOCOLS)
              )
  
          logger.debug("connection headers: %s", headers)
  
          return headers