fastly / pushpin

A proxy server for adding push to your API, used at the core of Fastly's Fanout service
https://pushpin.org
Apache License 2.0
3.66k stars 153 forks source link

apply next link response's own filters to its content #48069

Closed jkarneges closed 1 month ago

jkarneges commented 2 months ago

Currently, when the first response for a session is received, any specified filters are initialized before its body is processed. However, for each subsequent response received, any specified filters are initialized after its body is processed. This leads to an effect whereby the first response's body is processed by the first response's own filters, but all subsequent response bodies are processed using the previous response's filters (i.e. the second response body is processed by the first response's filters, the third response body is processed by the second response's filters, and so on).

This staggered behavior was likely unintentional. It would make more sense for each response's filters to be applied to its own body. This PR make the change.

I don't expect the change to cause any problems. In practice, backends using filters typically set the same ones in every response, in which case current and new behavior work out the same. And in the off-chance a backend changes filters mid-session, it is highly unlikely to be relying on current behavior. If anything, current behavior would probably break whatever the backend is trying to do.