Skip to content

Respect custom CheckOrigin on WebSocket upgrades#6

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/review-implementation-for-bugs
Draft

Respect custom CheckOrigin on WebSocket upgrades#6
Copilot wants to merge 2 commits intomasterfrom
copilot/review-implementation-for-bugs

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 24, 2026

The WebSocket acceptor was always overriding CheckOrigin, ignoring caller-provided origin policy.

  • Connection upgrade: Preserve a supplied websocket.Upgrader.CheckOrigin; only default to permissive origin when none is provided.
  • Coverage: Added test ensuring a rejecting CheckOrigin prevents upgrades and leaves the pool empty.
func (s *Stream) Accept(w http.ResponseWriter, r *http.Request, key string) error {
    if s.u.CheckOrigin == nil {
        s.u.CheckOrigin = func(*http.Request) bool { return true }
    }
    conn, err := s.u.Upgrade(w, r, nil)
    // ...
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: andrewwormald <20083774+andrewwormald@users.noreply.github.com>
Copilot AI changed the title [WIP] Review implementation for bugs and incomplete nuances Respect custom CheckOrigin on WebSocket upgrades Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants