Handle ErrBadRequest after HandleAnnounce is called

This commit is contained in:
Justin Li 2014-07-23 01:34:40 -04:00
parent 856568f1a8
commit 2a400a0419

View file

@ -42,19 +42,23 @@ func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprou
ann, err := NewAnnounce(s.config, r, p)
writer := &Writer{w}
if err == models.ErrMalformedRequest || err == models.ErrBadRequest {
if err == models.ErrMalformedRequest {
writer.WriteError(err)
return http.StatusOK, nil
} else if err != nil {
return http.StatusInternalServerError, err
}
if err = s.tracker.HandleAnnounce(ann, writer); err != nil {
err = s.tracker.HandleAnnounce(ann, writer)
if err == models.ErrBadRequest {
writer.WriteError(err)
return http.StatusOK, nil
} else if err != nil {
return http.StatusInternalServerError, err
}
stats.RecordEvent(stats.Announce)
return http.StatusOK, nil
}