diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-11-03 19:14:23 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-11-03 19:35:13 +0100 |
commit | 2d2c759ffe48f522987bc1bf7cd60829b2458c1b (patch) | |
tree | 8dc2f434721397ac1483ac1e122dfd44d68e93c5 /dev-python/httpbin | |
parent | dev-python/ruamel-yaml: Bump to 0.18.5 (diff) | |
download | gentoo-2d2c759ffe48f522987bc1bf7cd60829b2458c1b.tar.gz gentoo-2d2c759ffe48f522987bc1bf7cd60829b2458c1b.tar.bz2 gentoo-2d2c759ffe48f522987bc1bf7cd60829b2458c1b.zip |
dev-python/httpbin: Backport werkzeug-3 fix
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/httpbin')
-rw-r--r-- | dev-python/httpbin/files/httpbin-0.10.1-werkzeug-3.patch | 78 | ||||
-rw-r--r-- | dev-python/httpbin/httpbin-0.10.1-r3.ebuild | 42 |
2 files changed, 120 insertions, 0 deletions
diff --git a/dev-python/httpbin/files/httpbin-0.10.1-werkzeug-3.patch b/dev-python/httpbin/files/httpbin-0.10.1-werkzeug-3.patch new file mode 100644 index 000000000000..5ad6f2743400 --- /dev/null +++ b/dev-python/httpbin/files/httpbin-0.10.1-werkzeug-3.patch @@ -0,0 +1,78 @@ +diff --git a/httpbin/core.py b/httpbin/core.py +index 5c1783a1..a82c1b88 100644 +--- a/httpbin/core.py ++++ b/httpbin/core.py +@@ -32,7 +32,7 @@ + from werkzeug.wrappers import Response + except ImportError: # werkzeug < 2.1 + from werkzeug.wrappers import BaseResponse as Response +-from werkzeug.http import parse_authorization_header ++ + from flasgger import Swagger, NO_SANITIZER + + from . import filters +@@ -47,6 +47,7 @@ + H, + ROBOT_TXT, + ANGRY_ASCII, ++ parse_authorization_header, + parse_multi_value_header, + next_stale_after_value, + digest_challenge_response, +@@ -636,16 +637,13 @@ def redirect_to(): + args_dict = request.args.items() + args = CaseInsensitiveDict(args_dict) + +- # We need to build the response manually and convert to UTF-8 to prevent +- # werkzeug from "fixing" the URL. This endpoint should set the Location +- # header to the exact string supplied. + response = app.make_response("") + response.status_code = 302 + if "status_code" in args: + status_code = int(args["status_code"]) + if status_code >= 300 and status_code < 400: + response.status_code = status_code +- response.headers["Location"] = args["url"].encode("utf-8") ++ response.headers["Location"] = args["url"] + + return response + +diff --git a/httpbin/helpers.py b/httpbin/helpers.py +index b29e1835..836c8026 100644 +--- a/httpbin/helpers.py ++++ b/httpbin/helpers.py +@@ -13,8 +13,14 @@ + import time + import os + from hashlib import md5, sha256, sha512 +-from werkzeug.http import parse_authorization_header + from werkzeug.datastructures import WWWAuthenticate ++from werkzeug.http import dump_header ++ ++try: ++ from werkzeug.http import parse_authorization_header ++except ImportError: # werkzeug < 2.3 ++ from werkzeug.datastructures import Authorization ++ parse_authorization_header = Authorization.from_header + + from flask import request, make_response + from six.moves.urllib.parse import urlparse, urlunparse +@@ -466,9 +472,14 @@ def digest_challenge_response(app, qop, algorithm, stale = False): + ]), algorithm) + opaque = H(os.urandom(10), algorithm) + +- auth = WWWAuthenticate("digest") +- auth.set_digest('me@kennethreitz.com', nonce, opaque=opaque, +- qop=('auth', 'auth-int') if qop is None else (qop,), algorithm=algorithm) +- auth.stale = stale ++ values = { ++ 'realm': 'me@kennethreitz.com', ++ 'nonce': nonce, ++ 'opaque': opaque, ++ 'qop': dump_header(('auth', 'auth-int') if qop is None else (qop,)), ++ 'algorithm': algorithm, ++ 'stale': stale, ++ } ++ auth = WWWAuthenticate("digest", values=values) + response.headers['WWW-Authenticate'] = auth.to_header() + return response diff --git a/dev-python/httpbin/httpbin-0.10.1-r3.ebuild b/dev-python/httpbin/httpbin-0.10.1-r3.ebuild new file mode 100644 index 000000000000..c8dd0484fecb --- /dev/null +++ b/dev-python/httpbin/httpbin-0.10.1-r3.ebuild @@ -0,0 +1,42 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{10..12} pypy3 ) + +inherit distutils-r1 pypi + +DESCRIPTION="HTTP Request and Response Service" +HOMEPAGE=" + https://github.com/psf/httpbin/ + https://pypi.org/project/httpbin/ +" + +LICENSE="|| ( MIT ISC )" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" + +RDEPEND=" + dev-python/brotlicffi[${PYTHON_USEDEP}] + dev-python/decorator[${PYTHON_USEDEP}] + dev-python/flasgger[${PYTHON_USEDEP}] + >=dev-python/flask-2.2.4[${PYTHON_USEDEP}] + dev-python/itsdangerous[${PYTHON_USEDEP}] + dev-python/markupsafe[${PYTHON_USEDEP}] + dev-python/six[${PYTHON_USEDEP}] +" + +distutils_enable_tests pytest + +src_prepare() { + local PATCHES=( + # https://github.com/psf/httpbin/pull/29 + "${FILESDIR}/${P}-werkzeug-3.patch" + ) + + # unpin greenlet + sed -i -e '/greenlet/d' pyproject.toml || die + distutils-r1_src_prepare +} |