ianharrigan / hxWebSockets

hxWebSockets - websockets for all haxe platforms
https://github.com/ianharrigan/hxWebSockets
81 stars 18 forks source link

Option to set additional headers #12

Closed Tezar closed 5 years ago

Tezar commented 5 years ago

Adds option to postpone immediate connect upon new(). That enables to set additional headers in supported targets.

Partialy solves #11, but is IMHO more versatile solution. Setting cookies (and other headers such as custom user agent) can be now done easily without hustle of overriding.

var cookies = ["session" => "ABCD"];
var ws = new WebSocket("wss://...", false);
ws.additionalHeaders.set(
    "Cookie",
    [for (k in cookies.keys()) '${k}=${cookies[k]}'].join("; ")
);
ws.open();
ianharrigan commented 5 years ago

Thanks (again!) Tezar! :)