diff options
| author | Hsiaoming Yang <me@lepture.com> | 2018-02-13 18:24:07 +0900 |
|---|---|---|
| committer | Hsiaoming Yang <me@lepture.com> | 2018-02-13 18:24:07 +0900 |
| commit | e07303d989ba023b8edfea0754e6b2d8e4eebaaa (patch) | |
| tree | 4160ce135fb34c492be8531f543007b32e53664f | |
| parent | 8b1799738de72dd45d1136d943a049d45617ad09 (diff) | |
| download | werkzeug-patch-proxy.tar.gz | |
Fix ProxyMiddleware with query stringpatch-proxy
| -rw-r--r-- | tests/test_wsgi.py | 12 | ||||
| -rw-r--r-- | werkzeug/wsgi.py | 8 |
2 files changed, 15 insertions, 5 deletions
diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index 53a3a529..9d2f6807 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -480,7 +480,7 @@ def test_http_proxy(dev_server): return Response(u'%s|%s|%s' % ( request.headers.get('X-Special'), request.environ['HTTP_HOST'], - request.path, + request.full_path, )) ''' @@ -509,11 +509,15 @@ def test_http_proxy(dev_server): assert rv.data == b'ROOT' rv = client.get('/foo/bar') - assert rv.data.decode('ascii') == 'foo|faked.invalid|/foo/bar' + assert rv.data.decode('ascii') == 'foo|faked.invalid|/foo/bar?' rv = client.get('/bar/baz') - assert rv.data.decode('ascii') == 'bar|localhost|/baz' + assert rv.data.decode('ascii') == 'bar|localhost|/baz?' rv = client.get('/autohost/aha') - assert rv.data.decode('ascii') == 'None|%s|/autohost/aha' % url_parse( + assert rv.data.decode('ascii') == 'None|%s|/autohost/aha?' % url_parse( server.url).ascii_host + + # test query string + rv = client.get('/bar/baz?a=a&b=b') + assert rv.data.decode('ascii') == 'bar|localhost|/baz?a=a&b=b' diff --git a/werkzeug/wsgi.py b/werkzeug/wsgi.py index c30021a7..2d4498a4 100644 --- a/werkzeug/wsgi.py +++ b/werkzeug/wsgi.py @@ -545,7 +545,13 @@ class ProxyMiddleware(object): timeout=self.timeout, context=opts['ssl_context']) con.connect() - con.putrequest(environ['REQUEST_METHOD'], url_quote(remote_path), + + remote_url = url_quote(remote_path) + querystring = environ['QUERY_STRING'] + if querystring: + remote_url = remote_url + '?' + querystring + + con.putrequest(environ['REQUEST_METHOD'], remote_url, skip_host=True) for k, v in headers: |
