Created
January 29, 2014 07:51
-
-
Save ptarjan/8683534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/hphp/runtime/server/fastcgi/fastcgi-transport.cpp b/hphp/runtime/server/fastcgi/fastcgi-transport.cpp | |
index 0dcff6f..4c1e392 100644 | |
--- a/hphp/runtime/server/fastcgi/fastcgi-transport.cpp | |
+++ b/hphp/runtime/server/fastcgi/fastcgi-transport.cpp | |
@@ -56,8 +56,8 @@ const char *FastCGITransport::getUrl() { | |
return m_requestURI.c_str(); | |
} | |
-const std::string FastCGITransport::getScriptFilename() { | |
- return m_scriptFilename; | |
+const std::string FastCGITransport::getPathTranslated() { | |
+ return m_pathTranslated; | |
} | |
const std::string FastCGITransport::getDocumentRoot() { | |
@@ -335,7 +335,8 @@ void FastCGITransport::onHeadersComplete() { | |
m_serverAddr = getRawHeader("SERVER_ADDR"); | |
m_extendedMethod = getRawHeader("REQUEST_METHOD"); | |
m_httpVersion = getRawHeader("HTTP_VERSION"); | |
- m_scriptFilename = getRawHeader("SCRIPT_FILENAME"); | |
+ m_serverObject = getRawHeader("SCRIPT_NAME"); | |
+ m_pathTranslated = getRawHeader("PATH_TRANSLATED"); | |
m_documentRoot = getRawHeader("DOCUMENT_ROOT") + "/"; | |
try { | |
@@ -387,15 +388,11 @@ void FastCGITransport::onHeadersComplete() { | |
m_requestSize = 0; | |
} | |
- std::string pathTranslated = getRawHeader("PATH_TRANSLATED"); | |
- std::string documentRoot = getRawHeader("DOCUMENT_ROOT"); | |
- // use PATH_TRANSLATED - DOCUMENT_ROOT if it is valid instead of SCRIPT_NAME | |
- // for mod_fastcgi support | |
- if (!pathTranslated.empty() && !documentRoot.empty() && | |
- pathTranslated.find(documentRoot) == 0) { | |
- m_serverObject = pathTranslated.substr(documentRoot.length()); | |
- } else { | |
- m_serverObject = getRawHeader("SCRIPT_NAME"); | |
+ auto script_filename = getRawHeader("SCRIPT_FILENAME"); | |
+ if (!script_filename.empty() && m_pathTranslated.empty()) { | |
+ // If someone follows http://wiki.nginx.org/HttpFastcgiModule they won't | |
+ // pass in PATH_TRANSLATED and instead will just send SCRIPT_FILENAME | |
+ m_pathTranslated = script_filename; | |
} | |
std::string queryString = getRawHeader("QUERY_STRING"); | |
diff --git a/hphp/runtime/server/fastcgi/fastcgi-transport.h b/hphp/runtime/server/fastcgi/fastcgi-transport.h | |
index d5028a6..bedee13 100644 | |
--- a/hphp/runtime/server/fastcgi/fastcgi-transport.h | |
+++ b/hphp/runtime/server/fastcgi/fastcgi-transport.h | |
@@ -49,7 +49,7 @@ public: | |
virtual const char *getRemoteHost() override; | |
virtual const char *getRemoteAddr() override; | |
virtual uint16_t getRemotePort() override; | |
- virtual const std::string getScriptFilename() override; | |
+ virtual const std::string getPathTranslated() override; | |
virtual const std::string getDocumentRoot() override; | |
virtual const char *getServerName() override; | |
virtual const char *getServerAddr() override; | |
@@ -109,7 +109,7 @@ private: | |
folly::IOBufQueue m_bodyQueue; | |
std::unique_ptr<folly::IOBuf> m_currBody; | |
std::unordered_map<std::string, std::string> m_requestHeaders; | |
- std::string m_scriptFilename; | |
+ std::string m_pathTranslated; | |
std::string m_requestURI; | |
std::string m_documentRoot; | |
std::string m_remoteHost; | |
diff --git a/hphp/runtime/server/request-uri.cpp b/hphp/runtime/server/request-uri.cpp | |
index a094aea..03ac944 100644 | |
--- a/hphp/runtime/server/request-uri.cpp | |
+++ b/hphp/runtime/server/request-uri.cpp | |
@@ -72,7 +72,7 @@ bool RequestURI::process(const VirtualHost *vhost, Transport *transport, | |
m_originalURL = StringUtil::UrlDecode(m_originalURL, false); | |
m_rewritten = false; | |
- auto scriptFilename = transport->getScriptFilename(); | |
+ auto scriptFilename = transport->getPathTranslated(); | |
if (!scriptFilename.empty()) { | |
// The transport is overriding everything and just handing us the filename | |
m_path = m_absolutePath = scriptFilename; | |
diff --git a/hphp/runtime/server/transport.h b/hphp/runtime/server/transport.h | |
index bf189aa..a32b400 100644 | |
--- a/hphp/runtime/server/transport.h | |
+++ b/hphp/runtime/server/transport.h | |
@@ -117,7 +117,7 @@ public: | |
// The transport can override the virtualhosts' docroot | |
virtual const std::string getDocumentRoot() { return ""; } | |
// The transport can say exactly what script to use | |
- virtual const std::string getScriptFilename() { return ""; } | |
+ virtual const std::string getPathTranslated() { return ""; } | |
/** | |
* Server Headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment