From 35ccd5d9f978cf80a2643ee60b8d6c619678371b Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Tue, 17 Oct 2023 08:23:52 -0400 Subject: [PATCH] python3-httpbin: update to 0.10.1. --- srcpkgs/python3-httpbin/patches/brotli.patch | 28 +++++ .../python3-httpbin/patches/flask-3.0.patch | 110 ++++++++++++++++++ .../patches/werkzeug-2.1.patch | 61 ---------- srcpkgs/python3-httpbin/template | 16 +-- 4 files changed, 146 insertions(+), 69 deletions(-) create mode 100644 srcpkgs/python3-httpbin/patches/brotli.patch create mode 100644 srcpkgs/python3-httpbin/patches/flask-3.0.patch delete mode 100644 srcpkgs/python3-httpbin/patches/werkzeug-2.1.patch diff --git a/srcpkgs/python3-httpbin/patches/brotli.patch b/srcpkgs/python3-httpbin/patches/brotli.patch new file mode 100644 index 00000000000..534164cc508 --- /dev/null +++ b/srcpkgs/python3-httpbin/patches/brotli.patch @@ -0,0 +1,28 @@ +diff -ur python3-httpbin-0.10.1.orig/httpbin/filters.py python3-httpbin-0.10.1/httpbin/filters.py +--- python3-httpbin-0.10.1.orig/httpbin/filters.py 2023-10-17 08:12:56.814139485 -0400 ++++ python3-httpbin-0.10.1/httpbin/filters.py 2023-10-17 08:14:20.979514500 -0400 +@@ -10,7 +10,10 @@ + import gzip as gzip2 + import zlib + +-import brotlicffi as _brotli ++try: ++ import brotlicffi as _brotli ++except ImportError: ++ import brotli as _brotli + + from six import BytesIO + from decimal import Decimal +diff -ur python3-httpbin-0.10.1.orig/pyproject.toml python3-httpbin-0.10.1/pyproject.toml +--- python3-httpbin-0.10.1.orig/pyproject.toml 2023-10-17 08:12:56.816139494 -0400 ++++ python3-httpbin-0.10.1/pyproject.toml 2023-10-17 08:13:46.165359377 -0400 +@@ -32,7 +32,8 @@ + ] + dependencies = [ + "Flask", +- "brotlicffi", ++ "brotli; platform_python_implementation == 'CPython'", ++ "brotlicffi; platform_python_implementation != 'CPython'", + "decorator", + "flasgger", + 'greenlet < 3.0; python_version<"3.12"', diff --git a/srcpkgs/python3-httpbin/patches/flask-3.0.patch b/srcpkgs/python3-httpbin/patches/flask-3.0.patch new file mode 100644 index 00000000000..70b98e89141 --- /dev/null +++ b/srcpkgs/python3-httpbin/patches/flask-3.0.patch @@ -0,0 +1,110 @@ +From c1d9e33049263fed3cb27806a97f094acc350905 Mon Sep 17 00:00:00 2001 +From: Nate Prewitt +Date: Thu, 12 Oct 2023 08:30:42 -0700 +Subject: [PATCH] Support Flask 3.0 (#29) + +--- + httpbin/core.py | 8 +++----- + httpbin/helpers.py | 21 ++++++++++++++++----- + pyproject.toml | 3 +-- + 3 files changed, 20 insertions(+), 12 deletions(-) + +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/pyproject.toml b/pyproject.toml +index 020457ec..9454e569 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -31,15 +31,14 @@ classifiers = [ + "Programming Language :: Python :: 3.12", + ] + dependencies = [ +- "Flask", ++ "flask >= 2.2.4", + "brotli; platform_python_implementation == 'CPython'", + "brotlicffi; platform_python_implementation != 'CPython'", + "decorator", + "flasgger", + 'greenlet < 3.0; python_version<"3.12"', + 'greenlet >= 3.0.0a1; python_version>="3.12.0rc0"', + 'importlib-metadata; python_version<"3.8"', +- "werkzeug >= 0.14.1", + "six", + ] + diff --git a/srcpkgs/python3-httpbin/patches/werkzeug-2.1.patch b/srcpkgs/python3-httpbin/patches/werkzeug-2.1.patch deleted file mode 100644 index 4ac566edbf0..00000000000 --- a/srcpkgs/python3-httpbin/patches/werkzeug-2.1.patch +++ /dev/null @@ -1,61 +0,0 @@ -From df733e90032589861d93be78e22dbafc2f1dbea4 Mon Sep 17 00:00:00 2001 -From: Danil Shein -Date: Mon, 26 Sep 2022 15:26:00 +0300 -Subject: [PATCH] fix Werkzeug 2.1.x compatibility - -- fix httpbin/core.py: use Responce class instead of BaseResponse -see: https://github.com/pallets/werkzeug/pull/2276 -- fix tests: TestClient doesn't provide 'Content-Length' header anymore -see: https://github.com/pallets/werkzeug/issues/2347 ---- - httpbin/core.py | 7 +++++-- - test_httpbin.py | 4 ++-- - 2 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/httpbin/core.py b/httpbin/core.py -index 305c9882..d5c89eed 100644 ---- a/httpbin/core.py -+++ b/httpbin/core.py -@@ -29,7 +29,10 @@ - from six.moves import range as xrange - from werkzeug.datastructures import WWWAuthenticate, MultiDict - from werkzeug.http import http_date --from werkzeug.wrappers import BaseResponse -+try: -+ from werkzeug.wrappers import Response -+except ImportError: -+ from werkzeug.wrappers import BaseResponse as Response - from werkzeug.http import parse_authorization_header - from flasgger import Swagger, NO_SANITIZER - -@@ -77,7 +80,7 @@ def jsonify(*args, **kwargs): - - - # Prevent WSGI from correcting the casing of the Location header --BaseResponse.autocorrect_location_header = False -+Response.autocorrect_location_header = False - - # Find the correct template folder when running from a different location - tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates") -diff --git a/test_httpbin.py b/test_httpbin.py -index b7104ffc..87305ae6 100755 ---- a/test_httpbin.py -+++ b/test_httpbin.py -@@ -148,7 +148,7 @@ def test_get(self): - data = json.loads(response.data.decode('utf-8')) - self.assertEqual(data['args'], {}) - self.assertEqual(data['headers']['Host'], 'localhost') -- self.assertEqual(data['headers']['Content-Length'], '0') -+ # self.assertEqual(data['headers']['Content-Length'], '0') - self.assertEqual(data['headers']['User-Agent'], 'test') - # self.assertEqual(data['origin'], None) - self.assertEqual(data['url'], 'http://localhost/get') -@@ -162,7 +162,7 @@ def test_anything(self): - data = json.loads(response.data.decode('utf-8')) - self.assertEqual(data['args'], {}) - self.assertEqual(data['headers']['Host'], 'localhost') -- self.assertEqual(data['headers']['Content-Length'], '0') -+ # self.assertEqual(data['headers']['Content-Length'], '0') - self.assertEqual(data['url'], 'http://localhost/anything/foo/bar') - self.assertEqual(data['method'], 'GET') - self.assertTrue(response.data.endswith(b'\n')) diff --git a/srcpkgs/python3-httpbin/template b/srcpkgs/python3-httpbin/template index e74543a67fc..e6e8fc9bbd1 100644 --- a/srcpkgs/python3-httpbin/template +++ b/srcpkgs/python3-httpbin/template @@ -1,18 +1,18 @@ # Template file for 'python3-httpbin' pkgname=python3-httpbin -version=0.7.0 -revision=4 -build_style=python3-module -hostmakedepends="python3-setuptools" -depends="python3-Flask python3-decorator python3-six python3-Brotli - python3-raven python3-blinker" +version=0.10.1 +revision=1 +build_style=python3-pep517 +hostmakedepends="python3-setuptools python3-wheel" +depends="python3-Flask python3-Brotli python3-decorator python3-flasgger + python3-greenlet python3-six" checkdepends="python3-pytest $depends" short_desc="HTTP Request & Response Service" maintainer="Michal Vasilek " license="ISC" -homepage="https://github.com/postmanlabs/httpbin" +homepage="https://github.com/psf/httpbin" distfiles="${PYPI_SITE}/h/httpbin/httpbin-${version}.tar.gz" -checksum=cbb37790c91575f4f15757f42ad41d9f729eb227d5edbe89e4ec175486db8dfa +checksum=7b8596beb0e75a7b653c39d1f3cf263d6d5c476d29e1df6f7bb2b70bf9f06a3d post_install() { vlicense LICENSE