2
0
Эх сурвалжийг харах

[js] fix haxe.Http within macro when compiling with -D nodejs

Dan Korostelev 8 жил өмнө
parent
commit
8c3613ed0f

+ 7 - 7
std/haxe/Http.hx

@@ -34,7 +34,7 @@ import sys.net.Socket;
 
 
 	- call `haxe.Http.requestUrl(url)` and receive the result as a `String`
 	- call `haxe.Http.requestUrl(url)` and receive the result as a `String`
 	(not available on flash)
 	(not available on flash)
-	- create a `new haxe.Http(url)`, register your callbacks for `onData`, 
+	- create a `new haxe.Http(url)`, register your callbacks for `onData`,
 	`onError` and `onStatus`, then call `request()`.
 	`onError` and `onStatus`, then call `request()`.
 **/
 **/
 class Http {
 class Http {
@@ -188,7 +188,7 @@ class Http {
 	**/
 	**/
 	public function request( ?post : Bool ) : Void {
 	public function request( ?post : Bool ) : Void {
 		var me = this;
 		var me = this;
-	#if nodejs
+	#if (js && nodejs)
 		me.responseData = null;
 		me.responseData = null;
 		var parsedUrl = js.node.Url.parse(url);
 		var parsedUrl = js.node.Url.parse(url);
 		var secure = (parsedUrl.protocol == "https:");
 		var secure = (parsedUrl.protocol == "https:");
@@ -202,7 +202,7 @@ class Http {
 				arr = new Array<String>();
 				arr = new Array<String>();
 				Reflect.setField(h, i.header, arr);
 				Reflect.setField(h, i.header, arr);
 			}
 			}
-			
+
 			arr.push(i.value);
 			arr.push(i.value);
 		}
 		}
 		var uri = postData;
 		var uri = postData;
@@ -217,7 +217,7 @@ class Http {
 		}
 		}
 		var question = path.split("?").length <= 1;
 		var question = path.split("?").length <= 1;
 		if (!post && uri != null) path += (if( question ) "?" else "&") + uri;
 		if (!post && uri != null) path += (if( question ) "?" else "&") + uri;
-		
+
 		var opts = {
 		var opts = {
 			protocol: parsedUrl.protocol,
 			protocol: parsedUrl.protocol,
 			hostname: host,
 			hostname: host,
@@ -787,7 +787,7 @@ class Http {
 		This method is called upon a successful request, with `data` containing
 		This method is called upon a successful request, with `data` containing
 		the result String.
 		the result String.
 
 
-		The intended usage is to bind it to a custom function:  
+		The intended usage is to bind it to a custom function:
 		`httpInstance.onData = function(data) { // handle result }`
 		`httpInstance.onData = function(data) { // handle result }`
 	**/
 	**/
 	public dynamic function onData( data : String ) {
 	public dynamic function onData( data : String ) {
@@ -797,7 +797,7 @@ class Http {
 		This method is called upon a request error, with `msg` containing the
 		This method is called upon a request error, with `msg` containing the
 		error description.
 		error description.
 
 
-		The intended usage is to bind it to a custom function:  
+		The intended usage is to bind it to a custom function:
 		`httpInstance.onError = function(msg) { // handle error }`
 		`httpInstance.onError = function(msg) { // handle error }`
 	**/
 	**/
 	public dynamic function onError( msg : String ) {
 	public dynamic function onError( msg : String ) {
@@ -807,7 +807,7 @@ class Http {
 		This method is called upon a Http status change, with `status` being the
 		This method is called upon a Http status change, with `status` being the
 		new status.
 		new status.
 
 
-		The intended usage is to bind it to a custom function:  
+		The intended usage is to bind it to a custom function:
 		`httpInstance.onStatus = function(status) { // handle status }`
 		`httpInstance.onStatus = function(status) { // handle status }`
 	**/
 	**/
 	public dynamic function onStatus( status : Int ) {
 	public dynamic function onStatus( status : Int ) {