From 69070ed9b6678394b1ea6296a74d1ea2835f8b6d Mon Sep 17 00:00:00 2001 From: ericwu Date: Fri, 13 Oct 2023 17:24:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=95=E4=BD=93=E6=9C=8D=E5=8A=A1pypi?= =?UTF-8?q?=20simple=E9=87=8D=E5=AE=9A=E5=90=91=E5=88=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84url=20#1272?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pypi/artifact/repository/PypiLocalRepository.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt index 9f5e59ac5a..2ff8bf5ad8 100644 --- a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt +++ b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt @@ -104,7 +104,6 @@ import java.time.format.DateTimeFormatter import java.util.concurrent.LinkedBlockingQueue import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit -import javax.servlet.http.HttpServletRequest @Component class PypiLocalRepository( @@ -336,9 +335,8 @@ class PypiLocalRepository( /** * 本地调试删除 pypi.domain 配置 */ - fun getRedirectUrl(request: HttpServletRequest): String { + fun getRedirectUrl(path: String): String { val domain = pypiProperties.domain - val path = request.servletPath return UrlFormatter.format(domain, path).ensureSuffix(StringPool.SLASH) } @@ -346,11 +344,10 @@ class PypiLocalRepository( * */ fun getSimpleHtml(artifactInfo: ArtifactInfo): Any? { - val request = HttpContextHolder.getRequest() - if (!request.requestURI.endsWith("/")) { + val path = ArtifactContextHolder.getUrlPath(this.javaClass.name)!! + if (!path.endsWith("/")) { val response = HttpContextHolder.getResponse() - response.sendRedirect(getRedirectUrl(request)) - response.writer.flush() + response.sendRedirect(getRedirectUrl(path)) return null } with(artifactInfo) {