Prechádzať zdrojové kódy

Only check payload data if present.

Stefano Cossu 7 rokov pred
rodič
commit
2240052b52

+ 5 - 1
lakesuperior/endpoints/ldp.py

@@ -238,7 +238,11 @@ def class_from_req_body():
     logger.debug('stream: {}'.format(request.stream))
 
     # LDP-NR types
-    if  not request.mimetype or request.mimetype in accept_rdf:
+    if  not request.data:
+        logger.debug('No data received in body.')
+        cls = Ldpc
+        data = None
+    elif request.mimetype in accept_rdf:
         # Parse out the RDF string.
         data = request.data.decode('utf-8')
         g = Graph().parse(data=data, format=request.mimetype)

+ 3 - 1
lakesuperior/model/ldp_rs.py

@@ -92,7 +92,9 @@ class LdpRs(Ldpr):
         @param create_only (boolean) Whether the operation is a create-only
         one (i.e. POST) or a create-or-update one (i.e. PUT).
         '''
-        g = Graph().parse(data=data, format=format, publicID=self.urn)
+        g = Graph()
+        if data:
+            g.parse(data=data, format=format, publicID=self.urn)
 
         self.provided_imr = Resource(self._check_mgd_terms(g, handling),
                 self.urn)