cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

add reader middleware for processing response body data before save #52

Closed hbakhtiyor closed 7 months ago

hbakhtiyor commented 5 years ago

maybe you have another idea to achieve this, i need to decrypt body data before saving to file https://github.com/hbakhtiyor/gt/blob/fs/gt/fsend/download.go#L45-L59

cavaliercoder commented 5 years ago

This is really cool. I like this idea. We'll need to consider what happens if the given Reader returns a different byte count than has been returned by the remote server. This will affect other features and checks. Do you have any thoughts about this?

hbakhtiyor commented 5 years ago

here's version using the patch https://github.com/hbakhtiyor/gt/blob/fs/gt/cli/cli.go#L279-L288 here's the reader https://github.com/hbakhtiyor/openssl_gcm/blob/master/gcm_encrypt_reader.go#L38

yeah, stats is a bit messy, only downloaded bytes 2762815 and speed are correct

Downloading filename 2762815 / -1 bytes (-276281500%) - 112.00KBp/s ETA: -24s

the reader only reads bytes which indicated buf size in grab itself,

cavaliercoder commented 5 years ago

Similar (but different) to #57.