elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
6.06k stars 1.1k forks source link

Resolves #475 #477

Closed waggledans closed 2 years ago

waggledans commented 2 years ago

Resolves https://github.com/elazarl/goproxy/issues/475

Flush response body for server-side events to avoid events buffering by goproxy. I validated that it works with sse.

$ curl -x localhost:8080 localhost:3000/events
retry: 2000
id: 1
event: data
data: {"id":1,"data":"287039","time":"8:15:06 PM","final":false}
id: 2
event: data
data: {"id":2,"data":"267182","time":"8:15:07 PM","final":false}
id: 3
event: data
data: {"id":3,"data":"657946","time":"8:15:07 PM","final":false}
waggledans commented 2 years ago

I could add a test that starts a server and fetches events via the proxy but it would require updating dependencies in go.mod (and, ideally, setting go version to 1.17 to leverage modules graph pruning to avoid pulling go-sse to other packages that use goproxy). wdyt @elazarl ?

elazarl commented 2 years ago

@waggledans sounds good, I'll be happy to approve the PR