304
304
self.send_response(201)
305
305
self.end_headers()
307
class TestingDAVAppendRequestHandler(TestingDAVRequestHandler):
309
Subclass of TestingDAVRequestHandler implementing te APPEND command.
311
http://www.ietf.org/internet-drafts/draft-suma-append-patch-00.txt
312
propose two new commands: APPEND and PATCH. Their description
313
is sparse, this is a best effort attempt to implement the
317
"""Serve an APPEND request"""
318
path = self.translate_path(self.path)
319
trace.mutter("do_APPEND rel: [%s], abs: [%s]" % (self.path,path))
321
if self.headers.get('Expect') == '100-continue':
322
# Tell the client to go ahead, we're ready to get the content
323
self.send_response(100,"Continue")
327
# Always write in binary mode.
328
trace.mutter("do_APPEND will try to open: [%s]" % path)
329
f = open(path, 'wb+')
330
except (IOError, OSError), e :
331
self.send_error(409, "Conflict")
335
data = self.read_body()
337
except (IOError, OSError):
338
# FIXME: We leave a partially updated file here
339
self.send_error(409, "Conflict")
343
trace.mutter("do_APPEND done: [%s]" % self.path)
344
# FIXME: We should send 204 if the file didn't exist before
345
self.send_response(201)
349
308
class DAVServer(http_server.HttpServer):
350
309
"""Subclass of HttpServer that gives http+webdav urls.
362
321
_url_protocol = 'http+webdav'
365
class DAVServer_append(DAVServer):
366
"""Subclass of HttpServer that gives http+webdav urls.
368
This is for use in testing: connections to this server will always go
369
through pycurl where possible.
370
This server implements the proposed
371
(www.ietf.org/internet-drafts/draft-suma-append-patch-00.txt)
376
# We have special requests to handle that
377
# HttpServer_PyCurl don't know about
378
super(DAVServer_append,self).__init__(TestingDAVAppendRequestHandler)
380
# urls returned by this server should require the webdav client impl
381
_url_protocol = 'http+webdav'
384
324
class TestCaseWithDAVServer(tests.TestCaseWithTransport):
385
325
"""A support class that provides urls that are http+webdav://.