Skip to content
Snippets Groups Projects
Commit 8ef2dec0 authored by alice's avatar alice
Browse files

community/py3-httpbin: fix werkzeug compat

parent a42f79d4
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
pkgname=py3-httpbin pkgname=py3-httpbin
_pyname=httpbin _pyname=httpbin
pkgver=0.7.0 pkgver=0.7.0
pkgrel=3 pkgrel=4
pkgdesc="HTTP Request and Response Service" pkgdesc="HTTP Request and Response Service"
url=https://github.com/postmanlabs/httpbin url=https://github.com/postmanlabs/httpbin
arch="noarch" arch="noarch"
...@@ -11,7 +11,9 @@ depends="py3-flask py3-six py3-raven py3-blinker py3-brotli py3-decorator" ...@@ -11,7 +11,9 @@ depends="py3-flask py3-six py3-raven py3-blinker py3-brotli py3-decorator"
makedepends="py3-setuptools" makedepends="py3-setuptools"
_pypiprefix="${_pyname%${_pyname#?}}" _pypiprefix="${_pyname%${_pyname#?}}"
source="https://files.pythonhosted.org/packages/source/$_pypiprefix/$_pyname/$_pyname-$pkgver.tar.gz source="https://files.pythonhosted.org/packages/source/$_pypiprefix/$_pyname/$_pyname-$pkgver.tar.gz
0001-Use-Brotli-instead-of-brotlipy.patch" 0001-Use-Brotli-instead-of-brotlipy.patch
fix-werkzeug-compat.patch
"
builddir="$srcdir/$_pyname-$pkgver" builddir="$srcdir/$_pyname-$pkgver"
options="!check" # tests broken options="!check" # tests broken
...@@ -26,5 +28,9 @@ check() { ...@@ -26,5 +28,9 @@ check() {
package() { package() {
python3 setup.py install --prefix=/usr --root="$pkgdir" python3 setup.py install --prefix=/usr --root="$pkgdir"
} }
sha512sums="82e80058b58943637e9f8191764cea79bf7a6e40f36069f9b5d3f908585dbef20a03ef070d1f865d350920b6e874a93a48a544b05c14ff4911038ec2c20f6f63 httpbin-0.7.0.tar.gz
b39fdb02b642afab12aca14fe45e34af32cafb04c612e0be9b72ea5f4451c7d1ed412199dcbefcfc08cdf6699f61f177a49e9352965cadf2f65771922d73e61a 0001-Use-Brotli-instead-of-brotlipy.patch" sha512sums="
82e80058b58943637e9f8191764cea79bf7a6e40f36069f9b5d3f908585dbef20a03ef070d1f865d350920b6e874a93a48a544b05c14ff4911038ec2c20f6f63 httpbin-0.7.0.tar.gz
b39fdb02b642afab12aca14fe45e34af32cafb04c612e0be9b72ea5f4451c7d1ed412199dcbefcfc08cdf6699f61f177a49e9352965cadf2f65771922d73e61a 0001-Use-Brotli-instead-of-brotlipy.patch
edc9f9977bca27b24a3a3f69b72536dcd714d074ae74652d4a642627aad42b90359eb87eb1120ace19092bccad06db185b5b1b3d6a1541df01be09fdd9a9018e fix-werkzeug-compat.patch
"
Patch-Source: https://github.com/postmanlabs/httpbin/pull/684
From df733e90032589861d93be78e22dbafc2f1dbea4 Mon Sep 17 00:00:00 2001
From: Danil Shein <dshein@altlinux.org>
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'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment