aio-libs / aio-libs/aiohttp

Redirect on ws_connect gives confusing result

Offen
#3,678 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Python
Sterne
16.5k
Forks
2.4k
Ø Merge
17 Std. 22 Min.
Gemergte PRs (30 T.)
212

Beschreibung

## Long story short

I'm implementing a websocket service on existing HTTP server software. The server can be (and is by default) configured to redirect all HTTP traffic to HTTPS. The clients can choose to connect over HTTP or HTTPS. When connecting to `ws://service/ws` you will get a redirect to `https://service/ws` if the server is running with HTTP redirect to HTTPS.

Allowing `ws_connect(..., allow_redirects=False)` would at least allow me to detect this scenario without assuming that an HTTP 401 means "you got an HTTP Redirect, and followed it after dropping credentials."

## Expected behaviour

ws_connect('ws://service/ws', auth=auth) -> either a redirect related error or success

## Actual behaviour

The client gets HTTP 401, as credentials aren't included in the redirected request.

## Steps to reproduce

`ws_connect('ws://service/ws', auth=auth)` against a server that redirects HTTP traffic to HTTPS and requires basic auth.

## Your environment

Python 3.7.3rc1, aiohttp 3.5.1 (client)

Server is `nginx` with a `boost::beast` websocket service running behind a reverse proxy on `/ws`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.