Skip to content

Commit

Permalink
[server] Use req header for client info
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Jul 24, 2024
1 parent 66e1062 commit 626bc71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/pkg/controller/embedding/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *Controller) InsertOrUpdate(ctx *gin.Context, req ente.InsertOrUpdateEmb
Version: version,
EncryptedEmbedding: req.EncryptedEmbedding,
DecryptionHeader: req.DecryptionHeader,
Client: network.GetPrettyUA(ctx.GetHeader("User-Agent")) + "/" + ctx.GetHeader("X-Client-Version"),
Client: network.GetClientInfo(ctx),
}
size, uploadErr := c.uploadObject(obj, c.getObjectKey(userID, req.FileID, req.Model), c.derivedStorageDataCenter)
if uploadErr != nil {
Expand Down
10 changes: 10 additions & 0 deletions server/pkg/utils/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ func GetPrettyUA(ua string) string {
}
return parsedUA.UserAgent.Family + ", " + parsedUA.Os.ToString()
}

// GetClientInfo returns the client package and version from the request headers
func GetClientInfo(gin *gin.Context) string {
client := gin.GetHeader("X-Client-Package")
version := gin.GetHeader("X-Client-Version")
if version == "" {
return client
}
return client + "/" + version
}

0 comments on commit 626bc71

Please sign in to comment.