Exact format for WebSocket request header?

Not too my knowledge since websockets is an accepted standard to the point that WS is a “standard” lib that is just in browsers

Like fetch, websockets are just built into browsers.

You are trying to “reinvent the wheel” where people who wrote the spe, also wrote the “accepted” library to go with it.

IRC parsing is relatively mature and regexes, or tokensiers have been around for years.