Example #1
0
def sendMultiStatusResponse(environ, start_response, multistatusEL):
    # If logging of the body is desired, then this is the place to do it pretty:
    if environ.get("wsgidav.dump_response_body"):
        xml = "%s XML response body:\n%s" % (environ["REQUEST_METHOD"],
                                             xmlToString(multistatusEL, pretty_print=True)) 
        environ["wsgidav.dump_response_body"] = xml 
        
    # Hotfix for Windows XP 
    # PROPFIND XML response is not recognized, when pretty_print = True!
    # (Vista and others would accept this).
    xml_data = xmlToString(multistatusEL, pretty_print=False)
    
    headers = [
        ("Content-Type", "application/xml"),
        ("Date", getRfc1123Time()),
        ('Content-Length', str(len(xml_data))),
    ]

#    if 'keep-alive' in environ.get('HTTP_CONNECTION', '').lower():
#        headers += [
#            ('Connection', 'keep-alive'),
#        ]

    start_response("207 Multistatus", headers)
    assert type(xml_data) is str # If not, Content-Length is wrong!
    return [ xml_data ]
Example #2
0
def sendMultiStatusResponse(environ, start_response, multistatusEL):
    # If logging of the body is desired, then this is the place to do it pretty:
    if environ.get("wsgidav.dump_response_body"):
        xml = "%s XML response body:\n%s" % (environ["REQUEST_METHOD"],
                                             xmlToString(multistatusEL,
                                                         pretty_print=True))
        environ["wsgidav.dump_response_body"] = xml

    # Hotfix for Windows XP
    # PROPFIND XML response is not recognized, when pretty_print = True!
    # (Vista and others would accept this).
    xml_data = xmlToString(multistatusEL, pretty_print=False)

    headers = [
        ("Content-Type", "application/xml"),
        ("Date", getRfc1123Time()),
        ('Content-Length', str(len(xml_data))),
    ]

    #    if 'keep-alive' in environ.get('HTTP_CONNECTION', '').lower():
    #        headers += [
    #            ('Connection', 'keep-alive'),
    #        ]

    start_response("207 Multistatus", headers)
    assert type(xml_data) is str  # If not, Content-Length is wrong!
    return [xml_data]
Example #3
0
    if requestbody == "":
        if allowEmpty:
            return None
        else:
            raise DAVError(HTTP_BAD_REQUEST, "Body must not be empty.")
    
    try:
        rootEL = etree.fromstring(requestbody)
    except Exception, e:
        raise DAVError(HTTP_BAD_REQUEST, "Invalid XML format.", srcexception=e)   
    
    # If dumps of the body are desired, then this is the place to do it pretty:
    if environ.get("wsgidav.dump_request_body"):
        write("%s XML request body:\n%s" % (environ["REQUEST_METHOD"], 
                                            xmlToString(rootEL, pretty_print=True)))
        environ["wsgidav.dump_request_body"] = False

    return rootEL
    

#def sendResponse(environ, start_response, body, content_type):
#    """Send a WSGI response for a HTML or XML string.""" 
#    assert content_type in ("application/xml", "text/html")
#
#    start_response(status, [("Content-Type", content_type), 
#                            ("Date", getRfc1123Time()),
#                            ("Content-Length", str(len(body))),
#                            ]) 
#    return [ body ]
    
Example #4
0
    if requestbody == "":
        if allowEmpty:
            return None
        else:
            raise DAVError(HTTP_BAD_REQUEST, "Body must not be empty.")

    try:
        rootEL = etree.fromstring(requestbody)
    except Exception, e:
        raise DAVError(HTTP_BAD_REQUEST, "Invalid XML format.", srcexception=e)

    # If dumps of the body are desired, then this is the place to do it pretty:
    if environ.get("wsgidav.dump_request_body"):
        write("%s XML request body:\n%s" %
              (environ["REQUEST_METHOD"], xmlToString(rootEL,
                                                      pretty_print=True)))
        environ["wsgidav.dump_request_body"] = False

    return rootEL


#def sendResponse(environ, start_response, body, content_type):
#    """Send a WSGI response for a HTML or XML string."""
#    assert content_type in ("application/xml", "text/html")
#
#    start_response(status, [("Content-Type", content_type),
#                            ("Date", getRfc1123Time()),
#                            ("Content-Length", str(len(body))),
#                            ])
#    return [ body ]
Example #5
0
    if requestbody == "":
        if allowEmpty:
            return None
        else:
            raise DAVError(HTTP_BAD_REQUEST, "Body must not be empty.")
    
    try:
        rootEL = etree.fromstring(requestbody)
    except Exception, e:
        raise DAVError(HTTP_BAD_REQUEST, "Invalid XML format.", srcexception=e)   
    
    # If dumps of the body are desired, then this is the place to do it pretty:
    if environ.get("wsgidav.dump_request_body"):
        write("%s XML request body:\n%s" % (environ["REQUEST_METHOD"], 
                                            xmlToString(rootEL, pretty_print=True)))
        environ["wsgidav.dump_request_body"] = False

    return rootEL
    

#def sendResponse(environ, start_response, body, content_type):
#    """Send a WSGI response for a HTML or XML string.""" 
#    assert content_type in ("application/xml", "text/html")
#
#    start_response(status, [("Content-Type", content_type), 
#                            ("Date", getRfc1123Time()),
#                            ("Content-Length", str(len(body))),
#                            ]) 
#    return [ body ]