psf / httpbin

HTTP Request & Response Service, written in Python + Flask.
https://httpbin.org
Other
54 stars 17 forks source link

Support Flask 3.0 #29

Closed nateprewitt closed 1 year ago

nateprewitt commented 1 year ago

This PR should get httpbin working with Flask 3.0. The other recent changes to get Flask 2.0 working in main already broke Flask<2.2.4 so I've updated the dependencies to correctly reflect what we're compatible with. This should also resolve #28.

This PR changes three primary pieces:

  1. Move to using the WWWAuthenticate constructor that was introduced in werkzeug 2.0 and became the only supported interface in werkzeug 3.0.
  2. Move to Authorization.from_header which was introduced in werkzeug 2.3 and is the only supported interface in werkzeug 3.0. parse_authorization_header was already an alias for this in versions of werkzeug we support.
  3. We were doing some unneeded byte conversion for the Location header on redirect. This was a legacy change from 10 years ago to accommodate werkzeug casting all headers to str so we ensured they were utf-8 bytes. werkzeug stopped this conversion in 3.0 and we already have a Python 3 utf-8 string as input. We should be able drop this safely with our support range.