Skip to content

Commit

Permalink
Do not set cookies when keep-alive is true (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodangelis authored Mar 14, 2022
1 parent a762e15 commit 63dc102
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func New(cfg *config.Config) (*Server, error) {
// Create handlers
// Send handler (sends file to caller)
http.HandleFunc("/send/"+path, func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.Header.Get("User-Agent"), "Mozilla") {
if !cfg.KeepAlive && strings.HasPrefix(r.Header.Get("User-Agent"), "Mozilla") {
fmt.Println("new req...")
if cookie.Value == "" {
initCookie.Do(func() {
value, err := util.GetSessionID()
Expand Down Expand Up @@ -212,9 +213,7 @@ func New(cfg *config.Config) (*Server, error) {
// Increment the waitgroup
waitgroup.Add(1)
}
}
// Remove connection from the waitgroup when done
if !cfg.KeepAlive {
// Remove connection from the waitgroup when done
defer waitgroup.Done()
}
w.Header().Set("Content-Disposition", "attachment; filename="+
Expand Down

0 comments on commit 63dc102

Please sign in to comment.