iota.lib.csharp
iota.lib.csharp copied to clipboard
https compatibility
Hello,
Nice work by all contribs!
To get the lib working with carriota field HTTPS I had to modify:
private GenericIotaCoreApi.CreateBaseUrl() to:
private string CreateBaseUrl()
{
if(_host.Contains("http://") || _host.Contains("https://"))
{
return _host + ":" + _port;
}
return "http://" + _host + ":" + _port;
}
This allows http type to be optionally specified in the URL string of the main IotaApi constructor.
Great,I add a “protocol” param
Just for optimization of the code, the method could be something like this:
private string CreateBaseUrl()
{
var regex = new Regex("(http|https)+");
return regex.IsMatch(_host) ? (_host + ":" + _port) : ("http://" + _host + ":" + _port);
}
In the case of this workaround function: Instantiating and using Regex would incur more clock cycles and memory management than 2 in place string.Contains.
You are correct, although I think that in this case the memory consumption and/or computing power is relatively negligible, cause it has nothing to do with tangle-communication at all.
How ever it is solved, make it case-insensitive. One day I might be the idiot using "HTTP://" or "HttPs://"