-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A couple of baseurl-related fixes. #19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from __future__ import absolute_import | ||
import time | ||
from six.moves import urllib | ||
import random | ||
import uuid | ||
|
||
import logging | ||
|
||
|
@@ -95,7 +95,7 @@ def do_UNLOCK(self): | |
if self._l_isLocked(uri): | ||
self._l_delLock(token) | ||
|
||
self.send_body(None, 204, 'Ok', 'Ok') | ||
self.send_body(None, 204, 'OK', 'OK') | ||
|
||
def do_LOCK(self): | ||
""" Locking is implemented via in-memory caches. No data is written to disk. """ | ||
|
@@ -194,9 +194,7 @@ def isValid(self): | |
return (modified + timeout) > now | ||
|
||
def generateToken(self): | ||
_randGen = random.Random(time.time()) | ||
return '%s-%s-00105A989226:%.03f' % \ | ||
(_randGen.random(),_randGen.random(),time.time()) | ||
return str(uuid.uuid4()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice cleanup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I checked the output from Apache's DAV module and saw that it was returning a UUID, for the lock token, and the example on The top Google hit for "webdav lock token" did the same... since the |
||
|
||
def getTimeoutString(self): | ||
t = str(self.timeout) | ||
|
@@ -211,7 +209,7 @@ def asXML(self, namespace='d', discover=False): | |
owner_str = '' | ||
if isinstance(self.owner, str): | ||
owner_str = self.owner | ||
elif isinstance(self.owner, xml.dom.minicompat.NodeList): | ||
elif isinstance(self.owner, xml.dom.minicompat.NodeList) and len(self.owner) > 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be equivalent to just |
||
owner_str = "".join([node.toxml() for node in self.owner[0].childNodes]) | ||
|
||
token = self.token | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the newline isn't still needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
I'd say it's desirable, and I didn't intend to exclude it... but it didn't break the clients I was using to test (cadaver, davfs2, and GLib gio/gvfs).
Having said that, I'd like to move where that newline's getting generated a bit further down into the implementation, as it feels like it's part of a complete well-formed response. I'm thinking at the end of the
return doc.toxml(encoding="utf-8")
clauses on lines 119 and 183 of propfind.py. Does that sound reasonable?(Also, I'm pretty sure the
DATA = '%s\n' % rp.createResponse()
line just below here in thedo_REPORT()
method has the same fundamental issue, I just didn't notice it before. I'll make a fix for that, as soon as I figure out how to get a WebDAV client to elicit that response from the server.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get what you mean, this doesn't really look like the right place for it. I think http generally ignores extra newlines anyway so doesn't entirely surprise me the clients still work. Consolidating the place that adds them is a good idea though.