fringd / zipline

A gem that lets you stream a zip file from rails
MIT License
288 stars 68 forks source link

fix rails 7 compatibility #93

Closed symmetreDenis closed 7 months ago

symmetreDenis commented 8 months ago

by @fizvlad

I'll save some time to anyone trying to find the rails diff which resulted in this

self.response_body = zip_generator within gem calls response_body= method within rails, which calls body= on Response object, which results in assigning of Buffer built based of unchanged ZipGenerator to stream attribute of buffer

While responding Puma checks whether response body responds to to_ary and it does since this change and this change in Rails repo. Then this to_ary method is called on ZipGenerator. However Puma does additional check on the result of this method with array_body.is_a?(Array) and falls back to body = res_body if this check doesn't pass. I believe this PR only works due to Puma making this check and much better option would be supporting call of ZipGenerator#each w/o block. Rack also supports call method for "streaming body", but I'm not sure it will work, with Buffer always responding to to_ary 🤔

resolves #91

stevenchanin commented 7 months ago

+1. Thanks @symmetreDenis!

vpiau commented 7 months ago

+1. Thanks @symmetreDenis!

freesteph commented 7 months ago

@fringd can we help you with anything to get this merged?

fringd commented 7 months ago

looks good. sorry for taking a bit to merge ^_^