def readData(self, rurl):

        assert(isinstance(rurl, URL))

        # Create WebDAV GET
        request = Get(self, rurl.relativeURL())
        dout = ResponseDataString()
        request.setData(dout)

        # Process it
        self.runSession(request)

        # Check response status
        if request.getStatusCode() != statuscodes.OK:
            self.handleHTTPError(request)
            return None

        # Look for ETag
        if request.getNewETag() is not None:

            etag = request.getNewETag()

            # Handle server bug: ETag value MUST be quoted per HTTP/1.1 S3.11
            if not etag.startswith('"'):
                etag = "\"%s\"" % (etag,)
        else:
            etag = None

        # Return data as a string and etag
        return dout.getData(), etag
示例#2
0
    def readData(self, rurl):

        assert (isinstance(rurl, URL))

        # Create WebDAV GET
        request = Get(self, rurl.relativeURL())
        dout = ResponseDataString()
        request.setData(dout)

        # Process it
        self.runSession(request)

        # Check response status
        if request.getStatusCode() != statuscodes.OK:
            self.handleHTTPError(request)
            return None

        # Look for ETag
        if request.getNewETag() is not None:

            etag = request.getNewETag()

            # Handle server bug: ETag value MUST be quoted per HTTP/1.1 S3.11
            if not etag.startswith('"'):
                etag = "\"%s\"" % (etag, )
        else:
            etag = None

        # Return data as a string and etag
        return dout.getData(), etag
示例#3
0
    def test_IfMatchHeader(self):

        server = Session("www.example.com")
        request = Get(server, "/")
        request.setData(None, etag="\"12345\"")
        hdrs = request.generateRequestHeader()
        self.assertFalse("If-None-Match:" in hdrs)
        self.assertTrue("If-Match: \"12345\"" in hdrs)
示例#4
0
    def test_IfMatchHeader(self):

        server = Session("www.example.com")
        request = Get(server, "/")
        request.setData(None, etag="\"12345\"")
        hdrs = request.generateRequestHeader()
        self.assertFalse("If-None-Match:" in hdrs)
        self.assertTrue("If-Match: \"12345\"" in hdrs)