Skip to content

Handle dart.io:WebSocket response status #32000

Open
@jimmyshiau

Description

Is it possible to add response.statusCode in WebSocketException?
for example when server response other statusCode, we can handle it in catchError

if (response.statusCode != HttpStatus.SWITCHING_PROTOCOLS ||
          response.headers[HttpHeaders.CONNECTION] == null ||
          !response.headers[HttpHeaders.CONNECTION]
              .any((value) => value.toLowerCase() == "upgrade") ||
          response.headers.value(HttpHeaders.UPGRADE).toLowerCase() !=
              "websocket") {
        error("Connection to '$uri' was not upgraded to websocket");
      }
``

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-io

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions