Commit 3ba5dd98 authored by Mudassar Khan's avatar Mudassar Khan
Browse files

fix scheme issue in iot api

parent 84493528
Loading
Loading
Loading
Loading
+5 −1
Changes for go-packages/meep-sss-mgr/http.go: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -163,10 +163,14 @@ func (http_mgr *SssMgrHttp) send(p_ctx SssMgrBindingProtocolContext) (err error,
	if to != p_ctx.name && !strings.Contains(to, "/") && p_ctx.name != "" {
		to = p_ctx.name + "/" + to
	}
	scheme := "https://"
	// Honor the scheme of the registered endpoint URI; fall back to the port when it is unknown
	scheme := p_ctx.scheme + "://"
	if p_ctx.scheme == "" {
		scheme = "https://"
		if p_ctx.port != 443 {
			scheme = "http://"
		}
	}
	basePath := strings.Trim(p_ctx.path, "/")
	if basePath != "" {
		url = scheme + p_ctx.host + ":" + strconv.Itoa(p_ctx.port) + "/" + basePath + "/" + to
+11 −0
Changes for go-packages/meep-sss-mgr/onem2m-mgr.go: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ type SssMgr struct {
	protocol             SssMgrBindingProtocol
	host                 string
	port                 int
	scheme               string
	path                 string
	cse_name             string
	hostId               string
@@ -53,6 +54,7 @@ type SssMgr struct {
type IotPlatformInfo struct {
	Address       string
	Port          int
	Scheme        string
	Name          string
	IotPlatformId string
	Aei           string
@@ -217,6 +219,7 @@ func NewSssMgr_with_uri(name string, namespace string, bindingProtocol string, u
	tm.bindingProtocol = bindingProtocol
	tm.host = u.Hostname()
	tm.port, err = strconv.Atoi(u.Port())
	tm.scheme = u.Scheme
	tm.path = u.Path
	if err != nil {
		tm.port = 443
@@ -316,6 +319,7 @@ func (tm *SssMgr) init() {
	registeredIotPlatformsMap[tm.hostId] = IotPlatformInfo{
		Address:       tm.host,
		Port:          tm.port,
		Scheme:        tm.scheme,
		Name:          tm.cse_name,
		IotPlatformId: tm.hostId,
	}
@@ -509,6 +513,7 @@ func (tm *SssMgr) populateSensors(iotPlatformInfo IotPlatformInfo, type_ string)
	var ctx = SssMgrBindingProtocolContext{
		host:   iotPlatformInfo.Address,
		port:   iotPlatformInfo.Port,
		scheme: iotPlatformInfo.Scheme,
		path:   tm.path,
		name:   iotPlatformInfo.Name,
		hostId: iotPlatformInfo.IotPlatformId,
@@ -754,6 +759,7 @@ func (tm *SssMgr) OneM2M_create(sensor SensorDiscoveryInfo, path string, origina
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: sensor.IotPlatformId,
@@ -866,6 +872,7 @@ func (tm *SssMgr) OneM2M_discovery(type_ string, iotPlatformId string, originato
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: iotPlatformId,
@@ -975,6 +982,7 @@ func (tm *SssMgr) OneM2M_get(path string, iotPlatformId string, originator strin
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: iotPlatformId,
@@ -1046,6 +1054,7 @@ func (tm *SssMgr) OneM2M_subscribe(iotPlatformId string, path string, originator
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: iotPlatformId,
@@ -1163,6 +1172,7 @@ func (tm *SssMgr) OneM2M_delete(sensor SensorDiscoveryInfo, originator string) (
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: sensor.IotPlatformId,
@@ -1224,6 +1234,7 @@ func (tm *SssMgr) OneM2M_delete_subscription(subId string, originator string) (e
	var ctx = SssMgrBindingProtocolContext{
		host:   pltf.Address,
		port:   pltf.Port,
		scheme: pltf.Scheme,
		path:   tm.path,
		name:   pltf.Name,
		hostId: sub.IotPlatformId,