{"record":{"id":"3e573824ab4d9ea1","repo":"nats-io/nats-server","slug":"http-statustext-status","errorCode":null,"errorMessage":"http.StatusText(status)","messagePattern":"http\\.StatusText\\(status\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/websocket.go","lineNumber":1025,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t\tif snc && cnc {\n\t\t\t\t\t\t\treturn true, true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn true, false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false, false\n}\n\n// Send an HTTP error with the given `status` to the given http response writer `w`.\n// Return an error created based on the `reason` string.\nfunc wsReturnHTTPError(w http.ResponseWriter, r *http.Request, status int, reason string) error {\n\terr := fmt.Errorf(\"%s - websocket handshake error: %s\", r.RemoteAddr, reason)\n\tw.Header().Set(\"Sec-Websocket-Version\", \"13\")\n\thttp.Error(w, http.StatusText(status), status)\n\treturn err\n}\n\n// If the server is configured to accept any origin, then this function returns\n// `nil` without checking if the Origin is present and valid. This is also\n// the case if the request does not have the Origin header.\n// Otherwise, this will check that the Origin matches the same origin or\n// any origin in the allowed list.\nfunc (w *srvWebsocket) checkOrigin(r *http.Request) error {\n\tw.mu.RLock()\n\tcheckSame := w.sameOrigin\n\tlistEmpty := len(w.allowedOrigins) == 0\n\tw.mu.RUnlock()\n\tif !checkSame && listEmpty {\n\t\treturn nil\n\t}\n\torigin := r.Header.Get(\"Origin\")\n\tif origin == _EMPTY_ {","sourceCodeStart":1007,"sourceCodeEnd":1043,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/websocket.go#L1007-L1043","documentation":"The HTTP status line text produced by wsReturnHTTPError() when writing the error body via http.Error(). Not a distinct error condition: it renders the human-readable name (e.g. '403 Forbidden') of the status passed for the failed websocket handshake, accompanying the '%s - websocket handshake error: %s' error.","triggerScenarios":"Thrown at server/websocket.go:1025 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the accompanying handshake error and status code to determine why the upgrade was refused","Fix the client request or server websocket options per the reported reason"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}