iota.lib.csharp icon indicating copy to clipboard operation
iota.lib.csharp copied to clipboard

https compatibility

Open SiliconDroid opened this issue 7 years ago • 5 comments
trafficstars

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.

SiliconDroid avatar Apr 03 '18 16:04 SiliconDroid

Great,I add a “protocol” param

guojiancong avatar Apr 04 '18 01:04 guojiancong

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);
}

cordellcp3 avatar Apr 04 '18 08:04 cordellcp3

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.

SiliconDroid avatar Apr 04 '18 13:04 SiliconDroid

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.

cordellcp3 avatar Apr 06 '18 11:04 cordellcp3

How ever it is solved, make it case-insensitive. One day I might be the idiot using "HTTP://" or "HttPs://"

interware avatar May 24 '18 20:05 interware