~andidog/bzr-webdav/empty-put-request-bug

« back to all changes in this revision

Viewing changes to tests/dav_server.py

  • Committer: Vincent Ladeuil
  • Date: 2008-06-09 08:14:50 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20080609081450-xvf1ilxvwdvf9st5
Get rid of the APPEND experiments, this is not going to be supported anytime soon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
            self.send_response(201)
305
305
            self.end_headers()
306
306
 
307
 
class TestingDAVAppendRequestHandler(TestingDAVRequestHandler):
308
 
    """
309
 
    Subclass of TestingDAVRequestHandler implementing te APPEND command.
310
 
 
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
314
 
    APPEND command.
315
 
    """
316
 
    def do_APPEND(self):
317
 
        """Serve an APPEND request"""
318
 
        path = self.translate_path(self.path)
319
 
        trace.mutter("do_APPEND rel: [%s], abs: [%s]" % (self.path,path))
320
 
 
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")
324
 
            self.end_headers()
325
 
 
326
 
        try:
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")
332
 
            return
333
 
 
334
 
        try:
335
 
            data = self.read_body()
336
 
            f.write(data)
337
 
        except (IOError, OSError):
338
 
            # FIXME: We leave a partially updated file here
339
 
            self.send_error(409, "Conflict")
340
 
            f.close()
341
 
            return
342
 
        f.close()
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)
346
 
        self.end_headers()
347
 
 
348
307
 
349
308
class DAVServer(http_server.HttpServer):
350
309
    """Subclass of HttpServer that gives http+webdav urls.
362
321
    _url_protocol = 'http+webdav'
363
322
 
364
323
 
365
 
class DAVServer_append(DAVServer):
366
 
    """Subclass of HttpServer that gives http+webdav urls.
367
 
 
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)
372
 
    APPEND request.
373
 
    """
374
 
 
375
 
    def __init__(self):
376
 
        # We    have   special    requests    to   handle    that
377
 
        # HttpServer_PyCurl don't know about
378
 
        super(DAVServer_append,self).__init__(TestingDAVAppendRequestHandler)
379
 
 
380
 
    # urls returned by this server should require the webdav client impl
381
 
    _url_protocol = 'http+webdav'
382
 
 
383
 
 
384
324
class TestCaseWithDAVServer(tests.TestCaseWithTransport):
385
325
    """A support class that provides urls that are http+webdav://.
386
326