From 98aca177ce04dc180362b47bb5160c832995ae85 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 5 Oct 2015 13:11:20 +0200 Subject: [PATCH] WI-29096 "No input file specified" error with internal server --- .../src/org/jetbrains/builtInWebServer/PathInfo.kt | 2 +- .../builtInWebServer/DefaultWebServerPathHandler.kt | 5 +++-- .../src/org/jetbrains/io/fastCgi/FastCgiRequest.kt | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/platform/built-in-server-api/src/org/jetbrains/builtInWebServer/PathInfo.kt b/platform/built-in-server-api/src/org/jetbrains/builtInWebServer/PathInfo.kt index 7fdf66ccf8f4..366e080e87f4 100644 --- a/platform/built-in-server-api/src/org/jetbrains/builtInWebServer/PathInfo.kt +++ b/platform/built-in-server-api/src/org/jetbrains/builtInWebServer/PathInfo.kt @@ -22,7 +22,7 @@ class PathInfo(val ioFile: File?, val file: VirtualFile?, val root: VirtualFile, } if (file == null) { - builder.append(FileUtilRt.getRelativePath(FileUtilRt.toSystemIndependentName(ioFile!!.path), root.path, '/')) + builder.append(FileUtilRt.getRelativePath(root.path, FileUtilRt.toSystemIndependentName(ioFile!!.path), '/')) } else { builder.append(VfsUtilCore.getRelativePath(file, root, '/')) diff --git a/platform/built-in-server/src/org/jetbrains/builtInWebServer/DefaultWebServerPathHandler.kt b/platform/built-in-server/src/org/jetbrains/builtInWebServer/DefaultWebServerPathHandler.kt index 3ca6879f399d..ae9ffc15411d 100644 --- a/platform/built-in-server/src/org/jetbrains/builtInWebServer/DefaultWebServerPathHandler.kt +++ b/platform/built-in-server/src/org/jetbrains/builtInWebServer/DefaultWebServerPathHandler.kt @@ -16,6 +16,7 @@ package org.jetbrains.builtInWebServer import com.intellij.openapi.project.Project +import com.intellij.openapi.util.io.parentPath import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.util.PathUtilRt import io.netty.channel.ChannelHandlerContext @@ -76,8 +77,8 @@ private class DefaultWebServerPathHandler : WebServerPathHandler() { } else { // FallbackResource feature in action, /login requested, /index.php retrieved, we must not redirect /login to /login/ - if (path.endsWith(PathUtilRt.getFileName(PathUtilRt.getParentPath(pathInfo.path)))) { - WebServerPathHandler.redirectToDirectory(request, channel, if (isCustomHost) path else (projectName + '/' + path)) + if (path.endsWith(PathUtilRt.getFileName(pathInfo.path.parentPath!!))) { + WebServerPathHandler.redirectToDirectory(request, channel, if (isCustomHost) path else ("$projectName/$path")) return true } } diff --git a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt index 2843d8cb5ced..fab42264c91a 100644 --- a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt +++ b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt @@ -30,14 +30,14 @@ class FastCgiRequest(val requestId: Int, allocator: ByteBufAllocator) { buffer!!.writeZero(5) } - public fun writeFileHeaders(pathInfo: PathInfo, canonicalRequestPath: CharSequence) { + fun writeFileHeaders(pathInfo: PathInfo, canonicalRequestPath: CharSequence) { val root = pathInfo.root - addHeader("DOCUMENT_ROOT", root.path) - addHeader("SCRIPT_FILENAME", pathInfo.path) + addHeader("DOCUMENT_ROOT", root.path.separatorsToSystem()) + addHeader("SCRIPT_FILENAME", if (pathInfo.ioFile == null) pathInfo.file!!.path.separatorsToSystem() else pathInfo.ioFile!!.path) addHeader("SCRIPT_NAME", canonicalRequestPath) } - public fun addHeader(key: String, value: CharSequence?) { + fun addHeader(key: String, value: CharSequence?) { if (value == null) { return }