Skip to content

rewrite test client redirect handling#1402

Merged
davidism merged 1 commit into
masterfrom
test-client-redirect
Nov 25, 2018
Merged

rewrite test client redirect handling#1402
davidism merged 1 commit into
masterfrom
test-client-redirect

Conversation

@davidism

@davidism davidism commented Nov 25, 2018

Copy link
Copy Markdown
Member
  • EnvironBuilder.from_environ creates a builder from an existing environ. The previous code was passing EnvironBuilder(environ), but that doesn't mean anything to __init__.
  • Redirect environ is initialized from initial environ and passed to open, rather than passing only some args to open.
  • Script root and path are correctly distinguished. The root is preserved from the initial environ, stripped from the location, or cleared if the location is not under the root. Fixes Test client incorrectly follows redirects with a non-root base_url #382
  • HEAD method is not changed to GET.
  • Headers are passed to new request for all codes. There's nothing for or against passing them in the RFC, but Chrome, Firefox, and Requests all do this. Fixes Test Client does not keep Authorization in the request headers when following redirects #1151
  • Body and relevant headers are dropped except for 307 and 308. Previously the client would never pass on the body, it would only preserve the method for 307.
  • 1EnvironBuilder.get_environ` sets content type and length headers in addition to WSGI keys when detecting from data.
  • Better error message when disallowing domain redirects. Distinguishes between "subdomains aren't enabled" and "can't go to external host."
  • Test client recognizes 308 code.
  • Add 308 to http codes.

* EnvironBuilder can be initialized from an environ.
* Redirect environ is initialized from initial environ.
* Script root and path are correctly distinguished.
* HEAD method is not changed to GET.
* Headers are passed to new request for all codes.
* Body and relevant headers are dropped except for 307 and 308.
* EnvironBuilder sets content type and length headers from autodetection
* Better error message when disallowing domain redirects.
* Test client recognizes 308 code.
* Add 308 to http codes.
@davidism davidism force-pushed the test-client-redirect branch from 965bbc0 to d27ac6c Compare November 25, 2018 05:34
@davidism davidism merged commit b0302bb into master Nov 25, 2018
@davidism davidism deleted the test-client-redirect branch November 25, 2018 05:41
@davidism

Copy link
Copy Markdown
Member Author

Another change in #1403, intermediate redirect response bodies are exhausted even when buffered=False.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

1 participant