From a1d09e2cd7f06e4c7ca167b135c779f1ab415773 Mon Sep 17 00:00:00 2001 From: Alonza0314 Date: Wed, 15 Jan 2025 12:29:24 +0000 Subject: [PATCH] fix: wrong uri format in location header --- internal/sbi/processor/pdu_session.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/sbi/processor/pdu_session.go b/internal/sbi/processor/pdu_session.go index 7d670aeb..9f4fa17e 100644 --- a/internal/sbi/processor/pdu_session.go +++ b/internal/sbi/processor/pdu_session.go @@ -3,9 +3,11 @@ package processor import ( "encoding/hex" "errors" + "fmt" "net" "net/http" "reflect" + "strings" "github.com/gin-gonic/gin" @@ -253,7 +255,22 @@ func (p *Processor) HandlePDUSessionSMContextCreate( doSubscribe = true response.JsonData = smContext.BuildCreatedData() - c.Header("Location", smContext.Ref) + + // default location value will only be used in test environment + // in real environment, location value will be formatted as a full URI + location := smContext.Ref // this is the default location value + if c.Request != nil { + protocol := "http" + if c.Request.TLS != nil { + protocol += "s" + } + location = fmt.Sprintf("%s://%s%s/%s", + protocol, + c.Request.Host, + strings.TrimSuffix(c.Request.URL.Path, "/"), + strings.Split(smContext.Ref, ":")[2]) + } + c.Header("Location", location) c.JSON(http.StatusCreated, response) }