fix middleware gif, close #322