[server] Use req header for client info
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user