fix(master): redirect a cancelled Check now instead of an empty response (#35)
This commit is contained in:
@@ -1070,6 +1070,15 @@ func TestPollServiceOnlyThisService(t *testing.T) {
|
||||
require.Len(t, st.available, 1)
|
||||
assert.Equal(t, int64(1), st.available[0].id)
|
||||
assert.Equal(t, []string{ref}, reg.sortedCalls())
|
||||
for _, c := range st.pollErrors {
|
||||
assert.NotContains(t, c.ids, int64(2))
|
||||
}
|
||||
for _, c := range st.newer {
|
||||
assert.Equal(t, int64(1), c.id)
|
||||
}
|
||||
for _, c := range st.lastTag {
|
||||
assert.Equal(t, int64(1), c.id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPollServiceCancelled(t *testing.T) {
|
||||
|
||||
@@ -633,13 +633,15 @@ func (s *Server) pollService(w http.ResponseWriter, r *http.Request) {
|
||||
s.renderServiceError(w, r, id, http.StatusConflict, "Cannot check: "+np.Reason+".")
|
||||
return
|
||||
case r.Context().Err() != nil:
|
||||
return // the client is gone
|
||||
// The client is gone or the master is shutting down. Redirect anyway:
|
||||
// a browser still waiting gets the page, not an empty 200.
|
||||
case err != nil:
|
||||
s.failLookup(w, err)
|
||||
return
|
||||
default:
|
||||
sess, _ := webauth.SessionFrom(r.Context())
|
||||
s.log.Info("poll_requested", "service_id", id, "subject", sess.Subject)
|
||||
}
|
||||
sess, _ := webauth.SessionFrom(r.Context())
|
||||
s.log.Info("poll_requested", "service_id", id, "subject", sess.Subject)
|
||||
http.Redirect(w, r, "/services/"+strconv.FormatInt(id, 10), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user