http.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import http.server
  2. import sys
  3. from typing import Mapping, Tuple
  4. from . import __version__
  5. from .http_exceptions import HttpProcessingError as HttpProcessingError
  6. from .http_parser import (
  7. HeadersParser as HeadersParser,
  8. HttpParser as HttpParser,
  9. HttpRequestParser as HttpRequestParser,
  10. HttpResponseParser as HttpResponseParser,
  11. RawRequestMessage as RawRequestMessage,
  12. RawResponseMessage as RawResponseMessage,
  13. )
  14. from .http_websocket import (
  15. WS_CLOSED_MESSAGE as WS_CLOSED_MESSAGE,
  16. WS_CLOSING_MESSAGE as WS_CLOSING_MESSAGE,
  17. WS_KEY as WS_KEY,
  18. WebSocketError as WebSocketError,
  19. WebSocketReader as WebSocketReader,
  20. WebSocketWriter as WebSocketWriter,
  21. WSCloseCode as WSCloseCode,
  22. WSMessage as WSMessage,
  23. WSMsgType as WSMsgType,
  24. ws_ext_gen as ws_ext_gen,
  25. ws_ext_parse as ws_ext_parse,
  26. )
  27. from .http_writer import (
  28. HttpVersion as HttpVersion,
  29. HttpVersion10 as HttpVersion10,
  30. HttpVersion11 as HttpVersion11,
  31. StreamWriter as StreamWriter,
  32. )
  33. __all__ = (
  34. "HttpProcessingError",
  35. "RESPONSES",
  36. "SERVER_SOFTWARE",
  37. # .http_writer
  38. "StreamWriter",
  39. "HttpVersion",
  40. "HttpVersion10",
  41. "HttpVersion11",
  42. # .http_parser
  43. "HeadersParser",
  44. "HttpParser",
  45. "HttpRequestParser",
  46. "HttpResponseParser",
  47. "RawRequestMessage",
  48. "RawResponseMessage",
  49. # .http_websocket
  50. "WS_CLOSED_MESSAGE",
  51. "WS_CLOSING_MESSAGE",
  52. "WS_KEY",
  53. "WebSocketReader",
  54. "WebSocketWriter",
  55. "ws_ext_gen",
  56. "ws_ext_parse",
  57. "WSMessage",
  58. "WebSocketError",
  59. "WSMsgType",
  60. "WSCloseCode",
  61. )
  62. SERVER_SOFTWARE = "Python/{0[0]}.{0[1]} aiohttp/{1}".format(
  63. sys.version_info, __version__
  64. ) # type: str
  65. RESPONSES = (
  66. http.server.BaseHTTPRequestHandler.responses
  67. ) # type: Mapping[int, Tuple[str, str]]