def test_x_forward_proto(self):
class ChildController(object):
@expose()
def index(self):
redirect('/testing') # pragma: nocover
class RootController(object):
@expose()
def index(self):
redirect('/testing') # pragma: nocover
@expose()
def testing(self):
return 'it worked!' # pragma: nocover
child = ChildController()
app = TestApp(make_app(RootController(), debug=True))
res = app.get(
'/child', extra_environ=dict(HTTP_X_FORWARDED_PROTO='https')
)
# non-canonical url will redirect, so we won't get a 301
assert res.status_int == 302
# should add trailing / and changes location to https
assert res.location == 'https://localhost/child/'
assert res.request.environ['HTTP_X_FORWARDED_PROTO'] == 'https'
评论列表
文章目录