From 415011e162fad469801e5f5e88a11960f638bdbf Mon Sep 17 00:00:00 2001 From: Romain de Joux Date: Tue, 7 Apr 2020 22:03:11 +0200 Subject: s3api: Propagate backend PATH_INFO in environ for other middleware Use swift.backend_path entry in wsgi environment to propagate backend PATH_INFO. Needed by ceilometermiddleware to extract account/container info from PATH_INFO, patch: https://review.opendev.org/#/c/718085/ Change-Id: Ifb3c6c30835d912c5ba4b2e03f2e0b5cb392671a --- swift/common/middleware/s3api/s3request.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'swift/common/middleware/s3api/s3request.py') diff --git a/swift/common/middleware/s3api/s3request.py b/swift/common/middleware/s3api/s3request.py index fa39a68d8..28e734f0b 100644 --- a/swift/common/middleware/s3api/s3request.py +++ b/swift/common/middleware/s3api/s3request.py @@ -1332,6 +1332,12 @@ class S3Request(swob.Request): # reuse account _, self.account, _ = split_path(sw_resp.environ['PATH_INFO'], 2, 3, True) + # Propagate swift.backend_path in environ for middleware + # in pipeline that need Swift PATH_INFO like ceilometermiddleware. + # Store PATH_INFO only the first time to ignore multipart requests. + if 'swift.backend_path' not in self.environ: + self.environ['swift.backend_path'] = \ + sw_resp.environ['PATH_INFO'] resp = S3Response.from_swift_resp(sw_resp) status = resp.status_int # pylint: disable-msg=E1101 -- cgit v1.2.1