dart-lang / web_socket_channel

StreamChannel wrappers for WebSockets.
https://pub.dev/packages/web_socket_channel
BSD 3-Clause "New" or "Revised" License
423 stars 111 forks source link

How to send headers on web #242

Open kateile opened 1 year ago

kateile commented 1 year ago

Hi devs.

On other platforms I use the following implementation to send headers and it works really great.

IOWebSocketChannel.connect(
          url,
          protocols: protocols,
          headers: {'Authorization': "Bearer $accessToken"},
        );

Now problem comes on flutter web, since I can't use IOWebSocketChannel and WebSocketChannel doesn't have headers field. How can I archive the same thing on web?

aytunch commented 1 year ago

I need the same thing. I want clients to add unique id's to the headers so the server using web_socket_channel can differentiate them. Is there a solution for this on the web?

Snappy01 commented 1 year ago

i know it is not a in the specs of ws protocol, but it is needed indeed.

rhymelph commented 1 year ago

need too,is there any progress?

Matey2010 commented 1 year ago

Do you have any progress? It is really important in security purpose

santoshakil commented 1 year ago

any update ?

quetool commented 1 year ago

Nothing?

beheobong commented 7 months ago

I follow this step and success: https://stackoverflow.com/a/41521871

AliAltiyev commented 7 months ago

any update?

chertov commented 7 months ago

please! I need the headers too)

AndreyDAraya commented 1 week ago

Use this:


 import 'package:web_socket_channel/io.dart';

      _channel = IOWebSocketChannel.connect(
        url,
        headers: {
          'Authorization': 'Bearer $apiKey',
        },
      );