Skip to content

Commit

Permalink
fix: wrong uri format in location header
Browse files Browse the repository at this point in the history
Alonza0314 committed Jan 15, 2025
1 parent 145159f commit a1d09e2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/sbi/processor/pdu_session.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit a1d09e2

Please sign in to comment.