Opened 12 years ago

Last modified 9 years ago

#242 accepted defect

DAV module does not respect if-unmodified-since

Reported by: Marijn Haverbeke Owned by: somebody
Priority: minor Milestone:
Component: nginx-module Version: 1.3.x
Keywords: webdav Cc:
uname -a: Linux heffalump 2.6.38-15-generic #60-Ubuntu SMP Tue May 22 11:28:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Linux heffalump 2.6.38-15-generic #60-Ubuntu SMP Tue May 22 11:28:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Linux heffalump 2.6.38-15-generic #60-Ubuntu SMP Tue May 22 11:28:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Linux heffalump 2.6.38-15-generic #60-Ubuntu SMP Tue May 22 11:28:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Linux heffalump 2.6.38-15-generic #60-Ubuntu SMP Tue May 22 11:28:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.3.8
built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
configure arguments: --with-http_dav_module --prefix=/usr/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin

Description

I.e. if you PUT or DELETE a resource with an if-unmodified-since header, the overwrite or delete will go through happily even if the header should have prevented it.

(This is a common use case, where you've previously a version of a resource, and you know its modified date, and then, when updating it or deleting it, you want to check for race conditions with other clients, and can use if-unmodified-since to get an error back if someone else messed with the resource in the meantime.)

Find a patch for this attached (also at https://gist.github.com/4013062). It's my first Nginx contribution -- feel free to point out style mistakes or general wrong-headedness.

I did not find a clean way to make the existing code in ngx_http_not_modified_filter_module.c handle this. It looks directly at the last-modified header, and, as a header filter, will only run *after* the actions for the request have already been taken.

I also did not add code for if-match, which is analogous, and code for which could probably be added to the ngx_http_test_if_unmodified function I added (which would be renamed in that case). But I don't really understand handling of etags by nginx yet, so I didn't touch that.

Attachments (1)

nginx_dav_if-unmodified-since.patch (2.1 KB ) - added by Marijn Haverbeke 12 years ago.
Path that solves the problem for me

Download all attachments as: .zip

Change History (2)

by Marijn Haverbeke, 12 years ago

Path that solves the problem for me

comment:1 by Maxim Dounin, 9 years ago

sensitive: 0
Status: newaccepted
Note: See TracTickets for help on using tickets.