Пример #1
0
    def parsePropStat(self, propstat, result):
        # Scan the propstat node the status - we only process OK status

        # Now look for a <DAV:status> element in its children
        status = propstat.find(str(davxml.status))

        # Now parse the response and dispatch accordingly
        if status is not None:

            status_result = parseStatusLine(status.text)
            badstatus = status_result if status_result / 100 != 2 else None

            # Now look for a <DAV:prop> element in its children
            for item in propstat.findall(str(davxml.prop)):
                self.parseProp(item, result, badstatus)
Пример #2
0
    def parsePropStat(self, propstat, result):
        # Scan the propstat node the status - we only process OK status

        # Now look for a <DAV:status> element in its children
        status = propstat.find(str(davxml.status))

        # Now parse the response and dispatch accordingly
        if status is not None:

            status_result = parseStatusLine(status.text)
            badstatus = status_result if status_result / 100 != 2 else None

            # Now look for a <DAV:prop> element in its children
            for item in propstat.findall(str(davxml.prop)):
                self.parseProp(item, result, badstatus)
    def parseResponse(self, response):
        # Verify that the node is the correct element <DAV:response>
        if response.tag != davxml.response:
            self.others.add(response)
            return

        # Node is the right type, so iterate over all child response nodes and process each one
        result = PropFindParser.PropFindResult()
        for child in response.getchildren():

            # Is it the href
            if child.tag == davxml.href:
                result.setResource(child.text)

            # Is it propstat
            elif child.tag == davxml.propstat:
                self.parsePropStat(child, result)

            elif child.tag == davxml.status:
                result.setStatus(parseStatusLine(child.text))

        # Add the resource only if we got one
        if result.getResource():
            self.results[result.getResource()] = result
Пример #4
0
    def parseResponse(self, response):
        # Verify that the node is the correct element <DAV:response>
        if response.tag != davxml.response:
            self.others.add(response)
            return

        # Node is the right type, so iterate over all child response nodes and process each one
        result = PropFindParser.PropFindResult()
        for child in response.getchildren():

            # Is it the href
            if child.tag == davxml.href:
                result.setResource(child.text)

            # Is it propstat
            elif child.tag == davxml.propstat:
                self.parsePropStat(child, result)

            elif child.tag == davxml.status:
                result.setStatus(parseStatusLine(child.text))

        # Add the resource only if we got one
        if result.getResource():
            self.results[result.getResource()] = result
Пример #5
0
 def testParseTokenBadStatus(self):
     self.assertEqual(parseStatusLine("HTTP/1.2 2001 OK"), 0)
Пример #6
0
 def testParseTokenOK(self):
     self.assertEqual(parseStatusLine("HTTP/1.1 200 OK"), 200)
Пример #7
0
 def testParseTokenBad(self):
     self.assertEqual(parseStatusLine("HTTP/1.1"), 0)
Пример #8
0
 def testParseTokenBadVersion(self):
     self.assertEqual(parseStatusLine("HTTP/1.2 200 OK"), 0)
Пример #9
0
 def testParseTokenOK(self):
     self.assertEqual(parseStatusLine("HTTP/1.1 200 OK"), 200)
Пример #10
0
 def testParseTokenBad(self):
     self.assertEqual(parseStatusLine("HTTP/1.1"), 0)
Пример #11
0
 def testParseTokenBadVersion(self):
     self.assertEqual(parseStatusLine("HTTP/1.2 200 OK"), 0)
Пример #12
0
 def testParseTokenBadStatus(self):
     self.assertEqual(parseStatusLine("HTTP/1.2 2001 OK"), 0)