title: Responding to a WebSocket upgrade request
body: <p>I have a WebSocket server that gets WebSocket upgrade requests from different clients. Based on the query or path params of the request, sometimes the server needs to reject these upgrade requests. The server needs to cancel the handshake not because it does not support the protocol or because of a protocol violation by the client but because of  other reasons as mentioned.</p>
  <p>Is there a standard status code to respond with in this scenario? The <a href="https://www.rfc-editor.org/rfc/rfc6455#section-1.3" rel="nofollow noreferrer">specification</a> does not seem to define a response status code for this case. <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers" rel="nofollow noreferrer">Here</a> also it is mentioned that if it is a protocol violation by the client the server should respond with a &quot;400 Bad Request&quot; but no mention is made on the response to be sent if the server simply wants to cancel the handshake for some other reason.</p>
  <p>Can the server choose the respond with any status code without violating the protocol?</p>