MCPcopy
hub / github.com/aio-libs/aiohttp / StreamResponse

Class StreamResponse

aiohttp/web_reqrep.py:411–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409
410
411class StreamResponse(HeadersMixin):
412
413 def __init__(self, *, status=200, reason=None, headers=None):
414 self._body = None
415 self._keep_alive = None
416 self._chunked = False
417 self._chunk_size = None
418 self._compression = False
419 self._compression_force = False
420 self._headers = CIMultiDict()
421 self._cookies = http.cookies.SimpleCookie()
422 self.set_status(status, reason)
423
424 self._req = None
425 self._resp_impl = None
426 self._eof_sent = False
427 self._tcp_nodelay = True
428 self._tcp_cork = False
429
430 if headers is not None:
431 self._headers.extend(headers)
432
433 def _copy_cookies(self):
434 for cookie in self._cookies.values():
435 value = cookie.output(header='')[1:]
436 self.headers.add(hdrs.SET_COOKIE, value)
437
438 @property
439 def prepared(self):
440 return self._resp_impl is not None
441
442 @property
443 def started(self):
444 warnings.warn('use Response.prepared instead', DeprecationWarning)
445 return self.prepared
446
447 @property
448 def status(self):
449 return self._status
450
451 @property
452 def chunked(self):
453 return self._chunked
454
455 @property
456 def compression(self):
457 return self._compression
458
459 @property
460 def reason(self):
461 return self._reason
462
463 def set_status(self, status, reason=None):
464 self._status = int(status)
465 if reason is None:
466 reason = ResponseImpl.calc_reason(status)
467 self._reason = reason
468

Calls

no outgoing calls