diff --git a/stream.go b/stream.go index 13a83195..dfd40cce 100644 --- a/stream.go +++ b/stream.go @@ -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) }