Skip to content

Commit

Permalink
fix echo service
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbahkiry committed Sep 4, 2024
1 parent 61fd23c commit dd28aae
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions service/services/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func (e *Echo) Processing(partial bool, IcapHeader textproto.MIMEHeader) (int, i
isGzip := false

//extracting the file from http message
file, reqContentType, err := e.generalFunc.CopyingFileToTheBuffer(e.methodName)
_, reqContentType, err := e.generalFunc.CopyingFileToTheBuffer(e.methodName)
file, _ := e.httpMsg.StorageClient.Load(e.httpMsg.StorageKey)
if err != nil {
logging.Logger.Error(utils.PrepareLogMsg(e.xICAPMetadata, e.serviceName+" error: "+err.Error()))
logging.Logger.Info(utils.PrepareLogMsg(e.xICAPMetadata, e.serviceName+" service has stopped processing"))
Expand Down Expand Up @@ -66,19 +67,19 @@ func (e *Echo) Processing(partial bool, IcapHeader textproto.MIMEHeader) (int, i

//check if the file extension is a bypass extension
//if yes we will not modify the file, and we will return 204 No modifications
isProcess, icapStatus, httpMsg := e.generalFunc.CheckTheExtension(fileExtension, e.extArrs,
isProcess, _, _ := e.generalFunc.CheckTheExtension(fileExtension, e.extArrs,
e.processExts, e.rejectExts, e.bypassExts, e.return400IfFileExtRejected, isGzip,
e.serviceName, e.methodName, EchoIdentifier, e.httpMsg.Request.RequestURI, reqContentType, bytes.NewBuffer(file), utils.BlockPagePath, fileSize)
if !isProcess {
logging.Logger.Info(utils.PrepareLogMsg(e.xICAPMetadata, e.serviceName+" service has stopped processing"))
msgHeadersAfterProcessing = e.generalFunc.LogHTTPMsgHeaders(e.methodName)
return icapStatus, httpMsg, serviceHeaders, msgHeadersBeforeProcessing,
msgHeadersAfterProcessing, vendorMsgs
}
// if !isProcess {
// logging.Logger.Info(utils.PrepareLogMsg(e.xICAPMetadata, e.serviceName+" service has stopped processing"))
// msgHeadersAfterProcessing = e.generalFunc.LogHTTPMsgHeaders(e.methodName)
// return icapStatus, httpMsg, serviceHeaders, msgHeadersBeforeProcessing,
// msgHeadersAfterProcessing, vendorMsgs
// }

//check if the file size is greater than max file size of the service
//if yes we will return 200 ok or 204 no modification, it depends on the configuration of the service
if e.maxFileSize != 0 && e.maxFileSize < len(file) {
if e.maxFileSize != 0 && e.maxFileSize < len(file) && isProcess {
status, file, httpMsgAfter := e.generalFunc.IfMaxFileSizeExc(e.returnOrigIfMaxSizeExc, e.serviceName, e.methodName, bytes.NewBuffer(file), e.maxFileSize, utils.BlockPagePath, fileSize)
fileAfterPrep, httpMsgAfter := e.generalFunc.IfStatusIs204WithFile(e.methodName, status, file, isGzip, reqContentType, httpMsgAfter, true)
if fileAfterPrep == nil && httpMsgAfter == nil {
Expand Down

0 comments on commit dd28aae

Please sign in to comment.