-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability response body and response content type #18
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,10 @@ import ( | |
// The implementation of the Scan interceptor | ||
// | ||
type ScanInterceptor struct { | ||
VirusStatusCode int | ||
Scanner scanner.Scanner | ||
VirusStatusCode int | ||
VirusResponseBody string | ||
VirusResponseContentType string | ||
Scanner scanner.Scanner | ||
} | ||
|
||
/* | ||
|
@@ -113,8 +115,14 @@ func (c *ScanInterceptor) respondOnVirus(w http.ResponseWriter, filename string, | |
http.Error(w, "Internal Server Error", 500) | ||
return true | ||
} else if hasVirus { | ||
w.Header().Set("Content-Type", c.VirusResponseContentType) | ||
w.WriteHeader(c.VirusStatusCode) | ||
w.Write([]byte(fmt.Sprintf("File %s has a virus!", filename))) | ||
|
||
if len(c.VirusResponseBody) > 0 { | ||
w.Write([]byte(c.VirusResponseBody)) | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...remove this |
||
w.Write([]byte(fmt.Sprintf("File %s has a virus!", filename))) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we are losing the |
||
return true | ||
} | ||
return false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please set a default here, and...