Prechádzať zdrojové kódy

Allow urls without a / separating the path and query parts (#7564)

URLs such as http://example.com?a=1 are valid and should work (see #7563)
George Corney 6 rokov pred
rodič
commit
c85de49eff
1 zmenil súbory, kde vykonal 7 pridanie a 3 odobranie
  1. 7 3
      std/sys/Http.hx

+ 7 - 3
std/sys/Http.hx

@@ -103,8 +103,12 @@ class Http extends haxe.http.HttpBase {
 		var host = url_regexp.matched(2);
 		var portString = url_regexp.matched(3);
 		var request = url_regexp.matched(4);
-		if(request == "")
-			request = "/";
+		// ensure path begins with a forward slash
+		// this is required by original URL specifications and many servers have issues if it's not supplied
+		// see https://stackoverflow.com/questions/1617058/ok-to-skip-slash-before-query-string
+		if (request.charAt(0) != "/") {
+			request = "/" + request;
+		}
 		var port = if (portString == null || portString == "") secure ? 443:80 else Std.parseInt(portString.substr(1, portString.length - 1));
 
 		var multipart = (file != null);
@@ -456,4 +460,4 @@ class Http extends haxe.http.HttpBase {
 		h.request(false);
 		return r;
 	}
-}
+}