Browse Source

Convert underscores to hyphens in php client headers

All incoming headers are transformed by php to an underscore format in $_SERVER. For example `Content-type` is found in `$_SERVER['CONTENT_TYPE']`. To correctly get the header keys, the underscores need to be converted to hyphens again. Headers containing underscores are very rare and ignored in most webservers (apache, nginx).
Ben Merckx 9 years ago
parent
commit
abbde2a9e5
1 changed files with 2 additions and 2 deletions
  1. 2 2
      std/php/Web.hx

+ 2 - 2
std/php/Web.hx

@@ -209,10 +209,10 @@ class Web {
 			var h = Lib.hashOfAssociativeArray(untyped __php__("$_SERVER"));
 			for(k in h.keys()) {
 				if(k.substr(0,5) == "HTTP_") {
-					_client_headers.add({ header : k.substr(5), value : h.get(k)});
+					_client_headers.add({ header : k.substr(5).split('_').join('-'), value : h.get(k)});
 				// this is also a valid prefix (issue #1883)
 				} else if(k.substr(0,8) == "CONTENT_") {
-					_client_headers.add({ header : k, value : h.get(k)});
+					_client_headers.add({ header : k.split('_').join('-'), value : h.get(k)});
 				}
 			}
 		}