Skip to content

Commit

Permalink
fix request mode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbahkiry committed Sep 12, 2024
1 parent a859d32 commit 469274f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions service/services/clhashlookup/clhashlookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ func (d *Hashlookup) Processing(partial bool, IcapHeader textproto.MIMEHeader) (
ExceptionPagePath := utils.BlockPagePath
// fileExtension := d.generalFunc.GetMimeExtension(file, contentType[0], fileName)
var fileExtension string
filehead, err := d.httpMsg.StorageClient.ReadFileHeader(d.httpMsg.StorageKey)
if err != nil {
// Handle the error by extracting the file extension from the filename
logging.Logger.Warn(utils.PrepareLogMsg(d.xICAPMetadata,
"failed to read file header, falling back to file extension from filename: "+err.Error()))
fileExtension = filepath.Ext(fileName)[1:]
if d.methodName == utils.ICAPModeReq {
fileExtension = d.generalFunc.GetMimeExtension(file, contentType[0], fileName)
} else {
// Determine the file extension using the header data
fileExtension = d.generalFunc.GetMimeExtension(filehead, contentType[0], fileName)
filehead, err := d.httpMsg.StorageClient.ReadFileHeader(d.httpMsg.StorageKey)
if err != nil {
// Handle the error by extracting the file extension from the filename
logging.Logger.Warn(utils.PrepareLogMsg(d.xICAPMetadata,
"failed to read file header, falling back to file extension from filename: "+err.Error()))
fileExtension = filepath.Ext(fileName)[1:]
} else {
// Determine the file extension using the header data
fileExtension = d.generalFunc.GetMimeExtension(filehead, contentType[0], fileName)
}
}

d.FileHash, err = d.calculateFileHash(file)
if err != nil {
logging.Logger.Error(utils.PrepareLogMsg(d.xICAPMetadata, d.serviceName+" calculateFileHash error : "+err.Error()))
Expand Down

0 comments on commit 469274f

Please sign in to comment.