Added Secured flag for HttpRequest

This commit is contained in:
斟酌 鵬兄 2016-03-22 01:16:24 +08:00
parent 7ce7dec57c
commit 3ec995e193

View File

@ -37,6 +37,8 @@ class HttpRequest extends EventEmitter
this.Headers = Headers || {
"User-Agent": "BotanSS HttpRequest"
};
this.Secured = false;
}
SetUrl( Url )
@ -52,6 +54,7 @@ class HttpRequest extends EventEmitter
case "https://":
Url = Url.substr( 8 );
this.Port = 443;
this.Secured = true;
break;
}
@ -80,7 +83,7 @@ class HttpRequest extends EventEmitter
{
if( !this.Hostname ) throw new Error( "Url not set" );
var req = ( this.Port == 80 ? http : https )
var req = ( this.Secured ? https : http )
.request( this.Options, this.OnResponseReceived.bind( this ) );
req.end( this.RawPostData );
}