Reconsider and document redirect policy
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- go
- Ambito
- api, networking
Direzione di ricerca
Inizia da dial.go alle righe 76-103 e dalla documentazione della libreria che descrive DialOptions, quindi confronta il comportamento di reindirizzamento con la specifica WebSocket citata e le limitazioni di WASM. Chiarisci e documenta la policy attuale e determina se il valore predefinito debba cambiare in una versione futura; la issue #333 correlata fornisce ulteriore contesto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The problem
It looks like that by default the library uses the default HTTPClient:
https://github.com/coder/websocket/blob/d1468a75eee5525d183123766fbf288dca1eed9b/dial.go#L76-L103
And the default HTTP client does follow redirects:
// If CheckRedirect is nil, the Client uses its default policy,
// which is to stop after 10 consecutive requests.
Edit: actually, doesn't the fact that we do specify a CheckRedirect function mean that we do not stop after 10 consecutive requests?
I am aware that it is possible to provide your own HTTPClient struct to the Dial() function, and it is nice to rely on built-in defaults, I think a WebSocket library should be more concrete in this regard. Especially given the fact that this particular one claims to be able to target WASM. And, according to the browser WebSocket spec, redirects are not followed:
redirect mode is "error"
The reason redirects are not followed and this handshake is generally restricted is because it could introduce serious security problems in a web browser context. For example, consider a host with a WebSocket server at one path and an open HTTP redirector at another. Suddenly, any script that can be given a particular WebSocket URL can be tricked into communicating to (and potentially sharing secrets with) any host on the internet, even if the script checks that the URL has the right hostname.
This IMO can be considered an inconsistency between different targets.
Note that changing redirect policy for the WASM version is not possible, according to this library's docs:
HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op
For reference, the WebSocket spec itself states:
the server might redirect the client using a 3xx status code (but clients are not required to follow them)
Also for reference, the Gorilla WebSocket library IMU does not follow redirects, see this issue: https://github.com/gorilla/websocket/pull/965 and the code.
Suggested solution
- Document that the library follows redirects, but not in the WASM version.
- For the next version: Do not follow redirects by default, and document this.
This can either be considered a breaking change (so it goes to v2.x.x), or a bug fix.
Related issue: https://github.com/coder/websocket/issues/333
- Lingua principale
- Go
- Stelle
- 5.5k
- Fork
- 377
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di coder/websocket
-
Must not wrap io.EOF Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
export wstest Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
Tutte le issue di coder/websocket
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug group: validation priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
codecheckers/chekhov#51 ·
-
Creating worktree from an existing remote branch with a slash in it, has unexpected behaviour Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100