'Tests PUT method.'

def _PUT(self, domain_path):

    url = domain_path.url_join(rand_alpha(5))
    rnd_content = rand_alnum(6)
    headers = Headers([('content-type', 'text/plain')])
    put_response = self._uri_opener.PUT(url, data=rnd_content, headers=headers)
    res = self._uri_opener.GET(url, cache=True)
    if (res.get_body() == rnd_content):
        msg = 'File    upload    with    HTTP    PUT    method    was    found    at    resource:    "%s".    A    test    file    was    uploaded    to:    "%s".'
        msg = (msg % (domain_path, res.get_url()))
        v = Vuln('Publicly    writable    directory', msg, severity.HIGH, [put_response.id, res.id], self.get_name())
        v.set_url(url)
        v.set_method('PUT')
        self.kb_append(self, 'dav', v)
    elif (put_response.get_code() == 500):
        msg = ('DAV    seems    to    be    incorrectly    configured.    The    web    server    answered    with    a    500    error    code.    In    most    cases,    this    means    that    the    DAV    extension    failed    in    some    way.    This    error    was    found    at:    "%s".' % put_response.get_url())
        i = Info('DAV    incorrect    configuration', msg, res.id, self.get_name())
        i.set_url(url)
        i.set_method('PUT')
        self.kb_append(self, 'dav', i)
    elif (put_response.get_code() == 403):
        if ('supported' in put_response.get_body().lower()):
            return
        msg = 'DAV    seems    to    be    correctly    configured    and    allowing    you    to    use    the    PUT    method    but    the    directory    does    not    have    the    right    permissions    that    would    allow    the    web    server    to    write    to    it.    This    error    was    found    at:    "%s".'
        msg = (msg % put_response.get_url())
        i = Info('DAV    incorrect    configuration', msg, [put_response.id, res.id], self.get_name())
        i.set_url(url)
        i.set_method('PUT')
        self.kb_append(self, 'dav', i)
