MCPcopy Create free account
hub / github.com/python/cpython / set_content_length

Method set_content_length

Lib/wsgiref/handlers.py:205–215  ·  view source on GitHub ↗

Compute Content-Length or switch to chunked encoding if possible

(self)

Source from the content-addressed store, hash-verified

203
204
205 def set_content_length(self):
206 """Compute Content-Length or switch to chunked encoding if possible"""
207 try:
208 blocks = len(self.result)
209 except (TypeError,AttributeError,NotImplementedError):
210 pass
211 else:
212 if blocks==1:
213 self.headers['Content-Length'] = str(self.bytes_sent)
214 return
215 # XXX Try for chunked encoding if origin server and client is 1.1
216
217
218 def cleanup_headers(self):

Callers 1

cleanup_headersMethod · 0.95

Calls 1

strFunction · 0.85

Tested by

no test coverage detected