Created
January 28, 2014 22:20
-
-
Save ptarjan/8677794 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 d7f7501..39b1f84 100644 | |
--- a/hphp/runtime/server/fastcgi/fastcgi-transport.cpp | |
+++ b/hphp/runtime/server/fastcgi/fastcgi-transport.cpp | |
@@ -315,12 +315,6 @@ void FastCGITransport::onHeader(std::unique_ptr<folly::IOBuf> key_chain, | |
std::unique_ptr<folly::IOBuf> value_chain) { | |
Cursor cursor(key_chain.get()); | |
std::string key = cursor.readFixedString(key_chain->computeChainDataLength()); | |
- | |
- // HTTP has case insensitive header keys | |
- for (auto& c : key) { | |
- c = std::toupper(c); | |
- } | |
- | |
cursor = Cursor(value_chain.get()); | |
std::string value = cursor.readFixedString( | |
value_chain->computeChainDataLength()); | |
diff --git a/hphp/runtime/server/http-protocol.cpp b/hphp/runtime/server/http-protocol.cpp | |
index 205ab06..16e32f5 100644 | |
--- a/hphp/runtime/server/http-protocol.cpp | |
+++ b/hphp/runtime/server/http-protocol.cpp | |
@@ -221,6 +221,16 @@ void HttpProtocol::PrepareEnv(Variant& env, | |
env.set(s_HPHP_HOTPROFILER, 1); | |
#endif | |
} | |
+ | |
+ HeaderMap transportParams; | |
+ transport->getTransportParams(transportParams); | |
+ for (auto const& header : transportParams) { | |
+ String key(header.first); | |
+ String value(header.second.back()); | |
+ // These overwrite anything in the environment | |
+ g_context->setenv(key, value); | |
+ env.set(key, value); | |
+ } | |
} | |
void HttpProtocol::PrepareRequestVariables(Variant& request, | |
@@ -404,25 +414,15 @@ void HttpProtocol::CopyHeaderVariables(Variant& server, | |
} | |
void HttpProtocol::CopyTransportParams(Variant& server, | |
- Transport *transport) { | |
+ Transport *transport) { | |
HeaderMap transportParams; | |
// Get additional server params from the transport if it has any. In the case | |
// of fastcgi this is basically a full header list from apache/nginx. | |
transport->getTransportParams(transportParams); | |
for (auto const& header : transportParams) { | |
- auto const& key = header.first; | |
- auto const& values = header.second; | |
- auto normalizedKey = string_replace(f_strtoupper(key), s_dash, | |
- s_underscore); | |
- | |
- // Be careful here to not overwrite any _SERVER variable | |
- // that has already been set elsewhere and make sure it has a value. | |
- if (!values.empty() && !server.asArrRef().exists(normalizedKey)) { | |
- // When a header has multiple values, we always take the last one. | |
- server.set(normalizedKey, String(values.back())); | |
- } | |
+ // When a header has multiple values, we always take the last one. | |
+ server.set(String(header.first), String(header.second.back())); | |
} | |
- | |
} | |
void HttpProtocol::CopyServerInfo(Variant& server, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment