etix / mirrorbits

Mirrorbits is a geographical download redirector written in Go for distributing files efficiently across a set of mirrors.
MIT License
497 stars 90 forks source link

Evaluate If-Modified-Since header #131

Closed ott closed 2 months ago

ott commented 1 year ago

It was request in issue #115 to support the If-Modified-Since header. This is a first attempt to evaluate the If-Modified-Since header.

ott commented 1 year ago

@lazka This is a first attempt to support the If-Modified-Since header. Do you have the means to test this? I copied the source code from net/http, as suggested, so I don't expect major defects but there is no test suite and I don't have a test system at the moment.

ott commented 1 year ago

@etix Most of this pull request has been copied from net/http. How would you like me to attribute this? I will add the attribution to the commit message. However, I don't know whether I should add the attribution to the license header or the to every copied piece of source code.

jbkempf commented 8 months ago

That looks to me. I need to check the spec, but it seems logical.

elboulangero commented 3 months ago

Tested and it doesn't work. The code added is good, however the issue is that when checkIfModifiedSince is called, we don't know yet the mod time of the file. The function fileInfo := filesystem.NewFileInfo(urlPath) only initialize the struct with the file path and nothing else (check the code in question at https://github.com/etix/mirrorbits/pull/131/files#diff-c7bd264032bb4b6d96f25a74e79e88d7c9842f310bea423fb54f76297919a8efR287-R293)

I added the missing bits and propose a new MR: https://github.com/etix/mirrorbits/pull/169

elboulangero commented 3 months ago

This one can be closed as https://github.com/etix/mirrorbits/pull/169 was merged

jbkempf commented 2 months ago

See #169

jbkempf commented 2 months ago

And #169 is merged. Issue fixed.