http.pyi 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import typing
  2. from typing import AnyStr, Dict, List, Optional
  3. from twisted.internet.defer import Deferred
  4. from twisted.internet.interfaces import IAddress, ITCPTransport
  5. from twisted.logger import Logger
  6. from twisted.web.http_headers import Headers
  7. class HTTPChannel: ...
  8. class Request:
  9. # Instance attributes mentioned in the docstring
  10. method: bytes
  11. uri: bytes
  12. path: bytes
  13. args: Dict[bytes, List[bytes]]
  14. content: typing.BinaryIO
  15. cookies: List[bytes]
  16. requestHeaders: Headers
  17. responseHeaders: Headers
  18. notifications: List[Deferred[None]]
  19. _disconnected: bool
  20. _log: Logger
  21. # Other instance attributes set in __init__
  22. channel: HTTPChannel
  23. client: IAddress
  24. # This was hard to derive.
  25. # - `transport` is `self.channel.transport`
  26. # - `self.channel` is set in the constructor, and looks like it's always
  27. # an `HTTPChannel`.
  28. # - `HTTPChannel` is a `LineReceiver` is a `Protocol` is a `BaseProtocol`.
  29. # - `BaseProtocol` sets `self.transport` to initially `None`.
  30. #
  31. # Note that `transport` is set to an ITransport in makeConnection,
  32. # so is almost certainly not None by the time it reaches our code.
  33. #
  34. # I've narrowed this to ITCPTransport because
  35. # - we use `self.transport.abortConnection`, which belongs to that interface
  36. # - twisted does too! in its implementation of HTTPChannel.forceAbortClient
  37. transport: Optional[ITCPTransport]
  38. def getHeader(self, key: AnyStr) -> Optional[AnyStr]: ...
  39. def handleContentChunk(self, data: bytes) -> None: ...
  40. class PotentialDataLoss(Exception): ...