Return conflict when coder changed

monorepo
Varun Patil 2023-02-24 00:26:10 -08:00
parent d003a271bf
commit 3c2a405133
1 changed files with 7 additions and 0 deletions

View File

@ -307,6 +307,7 @@ func (s *Stream) waitForChunk(w http.ResponseWriter, chunk *Chunk) {
notif := make(chan bool)
chunk.notifs = append(chunk.notifs, notif)
t := time.NewTimer(10 * time.Second)
coder := s.coder
s.mutex.Unlock()
@ -332,6 +333,12 @@ func (s *Stream) waitForChunk(w http.ResponseWriter, chunk *Chunk) {
return
}
// Check if coder was changed
if coder != s.coder {
w.WriteHeader(http.StatusConflict)
return
}
// Return timeout error
w.WriteHeader(http.StatusRequestTimeout)
}