TheProjecter / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

Expose remote file's Content-MD5 header #118

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Feature request:

My use case:
I am writing a WebDAV client that downloads remote files while keeping the 
original remote file. It may happen that the remote file has been updated. For 
example, when the remote file is a log file. 
I run the client periodically and want to download only newer files while 
skipping existing files. But, if I have local file which has been updated 
remotely, I do want to download it overriding the local file.
In order to safely determine if my local and remote files are identical I use 
MD5. I don't want to download the whole remote file only to discover its MD5 
because it could be big. So I tell my server (Apache) to add Content-MD5 HTTP 
response header. 
Now I need a way to access this HTTP response header in the Sardine client 
side, from DavResource.

Implementation:
Of course it's easy to add additional field to DavResource containing the 
Content-MD5 header if exists, but I wonder if it's better to expose all HTTP 
response headers to DavResource. Since we're not writing a generic abstraction 
layer above WebDAV file system and therefore we don't have to avoid 
implementation-specific details, I thought it would be okay to expose HTTP 
headers, since WebDAV is by definition an extension to HTTP.

What do you think?

Original issue reported on code.google.com by david.pe...@gmail.com on 21 Mar 2012 at 5:21

GoogleCodeExporter commented 9 years ago
I see no reason to not expose the headers. Properly formatted patches are 
welcome.

One other way that I've implemented this in the past is to just store the MD5 
hash as a file next to the original. That way, I just download that tiny file 
first and then the actual file and then do the comparison.

Original comment by latch...@gmail.com on 21 Mar 2012 at 5:39

GoogleCodeExporter commented 9 years ago
You could extend Sardine to have the option to use a different response handler 
that returns headers from the server response. Attached some sample handlers. 
One would additionally need to extend the Sardine#get interface.

Original comment by dkocher@sudo.ch on 21 Jun 2012 at 4:54

GoogleCodeExporter commented 9 years ago

Original comment by dkocher@sudo.ch on 21 Jun 2012 at 4:55

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by dkocher@sudo.ch on 21 Jun 2012 at 4:55

Attachments: