Esempio n. 1
0
 def rwBody(self, bodyIn):
     if self.stream.reqMethod.upper(
     ) not in self.parent._filter_methods:
         return bodyIn
     if hdr.CONTENT_LENGTH(self.stream.headers) in (None, "", "0"):
         return bodyIn
     bodyOut = XMLRewriter(bodyIn)
     bodyOut.rewrite = self.parent.rewriteLocal
     bodyOut.rw_content["D:href"] = True
     return bodyOut
Esempio n. 2
0
 def _generateLines(self):
     if not hasattr(self.stream, "body"):
         self.stream.parse()
     if hasattr(self, "rwHeaders"):
         self.rwHeaders(self.stream.headers)
     # Yield the response line immediately, so the client knows
     # that there's something coming.
     yield self.stream.readline()
     # Ensure that content-length is correct, reading body if necessary
     hasCL = hdr.CONTENT_LENGTH(self.stream.headers)
     hasCL = hasCL not in (None, "", "0")
     if hasattr(self, "rwBody"):
         self.stream.body = self.rwBody(self.stream.body)
         if hasCL:
             body = []
             newCL = 0
             for ln in self.stream.body:
                 body.append(ln)
                 newCL += len(ln)
             self.stream.body = body
             hdr.CONTENT_LENGTH.update(self.stream.headers, newCL)
     for ln in self.stream:
         yield ln
Esempio n. 3
0
 def _getContentLength(self):
     cl = hdr.CONTENT_LENGTH(self.headers)
     if cl == "":
         cl = None
     return cl