koichi12 commited on
Commit
18859de
·
verified ·
1 Parent(s): 1a8ead7

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/.hash/_http_parser.pyx.hash +1 -0
  3. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/abc.cpython-311.pyc +0 -0
  4. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/base_protocol.cpython-311.pyc +0 -0
  5. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_exceptions.cpython-311.pyc +0 -0
  6. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_proto.cpython-311.pyc +0 -0
  7. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_reqrep.cpython-311.pyc +0 -0
  8. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_ws.cpython-311.pyc +0 -0
  9. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/compression_utils.cpython-311.pyc +0 -0
  10. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/connector.cpython-311.pyc +0 -0
  11. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/cookiejar.cpython-311.pyc +0 -0
  12. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/formdata.cpython-311.pyc +0 -0
  13. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_exceptions.cpython-311.pyc +0 -0
  14. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_websocket.cpython-311.pyc +0 -0
  15. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_writer.cpython-311.pyc +0 -0
  16. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/multipart.cpython-311.pyc +0 -0
  17. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/payload.cpython-311.pyc +0 -0
  18. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/payload_streamer.cpython-311.pyc +0 -0
  19. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/pytest_plugin.cpython-311.pyc +0 -0
  20. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/resolver.cpython-311.pyc +0 -0
  21. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/tcp_helpers.cpython-311.pyc +0 -0
  22. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/test_utils.cpython-311.pyc +0 -0
  23. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/tracing.cpython-311.pyc +0 -0
  24. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/typedefs.cpython-311.pyc +0 -0
  25. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web.cpython-311.pyc +0 -0
  26. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_app.cpython-311.pyc +0 -0
  27. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_exceptions.cpython-311.pyc +0 -0
  28. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_fileresponse.cpython-311.pyc +0 -0
  29. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_log.cpython-311.pyc +0 -0
  30. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_protocol.cpython-311.pyc +0 -0
  31. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_request.cpython-311.pyc +0 -0
  32. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_response.cpython-311.pyc +0 -0
  33. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_routedef.cpython-311.pyc +0 -0
  34. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_runner.cpython-311.pyc +0 -0
  35. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_server.cpython-311.pyc +0 -0
  36. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_urldispatcher.cpython-311.pyc +0 -0
  37. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_ws.cpython-311.pyc +0 -0
  38. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/worker.cpython-311.pyc +0 -0
  39. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_http_parser.pyx +837 -0
  40. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_http_writer.pyx +162 -0
  41. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/mask.pxd.hash +1 -0
  42. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/mask.pyx.hash +1 -0
  43. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/reader_c.pxd.hash +1 -0
  44. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__init__.py +1 -0
  45. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/__init__.cpython-311.pyc +0 -0
  46. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/helpers.cpython-311.pyc +0 -0
  47. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/models.cpython-311.pyc +0 -0
  48. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader.cpython-311.pyc +0 -0
  49. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader_c.cpython-311.pyc +0 -0
  50. .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader_py.cpython-311.pyc +0 -0
.gitattributes CHANGED
@@ -162,3 +162,4 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/_inductor/_
162
  .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/yarl/_quoting_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
163
  .venv/lib/python3.11/site-packages/ray/dag/__pycache__/compiled_dag_node.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
164
  .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/multidict/_multidict.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
162
  .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/yarl/_quoting_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
163
  .venv/lib/python3.11/site-packages/ray/dag/__pycache__/compiled_dag_node.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
164
  .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/multidict/_multidict.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
165
+ .venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/frozenlist/_frozenlist.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/.hash/_http_parser.pyx.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ c107400e3e4b8b3c02ffb9c51abf2722593a1a9a1a41e434df9f47d0730a1ae3 /home/runner/work/aiohttp/aiohttp/aiohttp/_http_parser.pyx
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/abc.cpython-311.pyc ADDED
Binary file (13.3 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/base_protocol.cpython-311.pyc ADDED
Binary file (4.95 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_exceptions.cpython-311.pyc ADDED
Binary file (20 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_proto.cpython-311.pyc ADDED
Binary file (13 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_reqrep.cpython-311.pyc ADDED
Binary file (59.6 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/client_ws.cpython-311.pyc ADDED
Binary file (23.5 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/compression_utils.cpython-311.pyc ADDED
Binary file (9.79 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/connector.cpython-311.pyc ADDED
Binary file (73.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/cookiejar.cpython-311.pyc ADDED
Binary file (23.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/formdata.cpython-311.pyc ADDED
Binary file (8.55 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_exceptions.cpython-311.pyc ADDED
Binary file (7.49 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_websocket.cpython-311.pyc ADDED
Binary file (1.11 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/http_writer.cpython-311.pyc ADDED
Binary file (11.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/multipart.cpython-311.pyc ADDED
Binary file (54.1 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/payload.cpython-311.pyc ADDED
Binary file (27.9 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/payload_streamer.cpython-311.pyc ADDED
Binary file (5.06 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/pytest_plugin.cpython-311.pyc ADDED
Binary file (21.1 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/resolver.cpython-311.pyc ADDED
Binary file (7.94 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/tcp_helpers.cpython-311.pyc ADDED
Binary file (2.05 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/test_utils.cpython-311.pyc ADDED
Binary file (37.1 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/tracing.cpython-311.pyc ADDED
Binary file (24.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/typedefs.cpython-311.pyc ADDED
Binary file (2.73 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web.cpython-311.pyc ADDED
Binary file (19.6 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_app.cpython-311.pyc ADDED
Binary file (30.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_exceptions.cpython-311.pyc ADDED
Binary file (18.2 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_fileresponse.cpython-311.pyc ADDED
Binary file (18.7 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_log.cpython-311.pyc ADDED
Binary file (11.7 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_protocol.cpython-311.pyc ADDED
Binary file (32.8 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_request.cpython-311.pyc ADDED
Binary file (41.4 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_response.cpython-311.pyc ADDED
Binary file (40.7 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_routedef.cpython-311.pyc ADDED
Binary file (12.9 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_runner.cpython-311.pyc ADDED
Binary file (20.8 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_server.cpython-311.pyc ADDED
Binary file (5.46 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_urldispatcher.cpython-311.pyc ADDED
Binary file (75.7 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/web_ws.cpython-311.pyc ADDED
Binary file (33.2 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/__pycache__/worker.cpython-311.pyc ADDED
Binary file (12.3 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_http_parser.pyx ADDED
@@ -0,0 +1,837 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #cython: language_level=3
2
+ #
3
+ # Based on https://github.com/MagicStack/httptools
4
+ #
5
+
6
+ from cpython cimport (
7
+ Py_buffer,
8
+ PyBUF_SIMPLE,
9
+ PyBuffer_Release,
10
+ PyBytes_AsString,
11
+ PyBytes_AsStringAndSize,
12
+ PyObject_GetBuffer,
13
+ )
14
+ from cpython.mem cimport PyMem_Free, PyMem_Malloc
15
+ from libc.limits cimport ULLONG_MAX
16
+ from libc.string cimport memcpy
17
+
18
+ from multidict import CIMultiDict as _CIMultiDict, CIMultiDictProxy as _CIMultiDictProxy
19
+ from yarl import URL as _URL
20
+
21
+ from aiohttp import hdrs
22
+ from aiohttp.helpers import DEBUG, set_exception
23
+
24
+ from .http_exceptions import (
25
+ BadHttpMessage,
26
+ BadHttpMethod,
27
+ BadStatusLine,
28
+ ContentLengthError,
29
+ InvalidHeader,
30
+ InvalidURLError,
31
+ LineTooLong,
32
+ PayloadEncodingError,
33
+ TransferEncodingError,
34
+ )
35
+ from .http_parser import DeflateBuffer as _DeflateBuffer
36
+ from .http_writer import (
37
+ HttpVersion as _HttpVersion,
38
+ HttpVersion10 as _HttpVersion10,
39
+ HttpVersion11 as _HttpVersion11,
40
+ )
41
+ from .streams import EMPTY_PAYLOAD as _EMPTY_PAYLOAD, StreamReader as _StreamReader
42
+
43
+ cimport cython
44
+
45
+ from aiohttp cimport _cparser as cparser
46
+
47
+ include "_headers.pxi"
48
+
49
+ from aiohttp cimport _find_header
50
+
51
+ ALLOWED_UPGRADES = frozenset({"websocket"})
52
+ DEF DEFAULT_FREELIST_SIZE = 250
53
+
54
+ cdef extern from "Python.h":
55
+ int PyByteArray_Resize(object, Py_ssize_t) except -1
56
+ Py_ssize_t PyByteArray_Size(object) except -1
57
+ char* PyByteArray_AsString(object)
58
+
59
+ __all__ = ('HttpRequestParser', 'HttpResponseParser',
60
+ 'RawRequestMessage', 'RawResponseMessage')
61
+
62
+ cdef object URL = _URL
63
+ cdef object URL_build = URL.build
64
+ cdef object CIMultiDict = _CIMultiDict
65
+ cdef object CIMultiDictProxy = _CIMultiDictProxy
66
+ cdef object HttpVersion = _HttpVersion
67
+ cdef object HttpVersion10 = _HttpVersion10
68
+ cdef object HttpVersion11 = _HttpVersion11
69
+ cdef object SEC_WEBSOCKET_KEY1 = hdrs.SEC_WEBSOCKET_KEY1
70
+ cdef object CONTENT_ENCODING = hdrs.CONTENT_ENCODING
71
+ cdef object EMPTY_PAYLOAD = _EMPTY_PAYLOAD
72
+ cdef object StreamReader = _StreamReader
73
+ cdef object DeflateBuffer = _DeflateBuffer
74
+ cdef bytes EMPTY_BYTES = b""
75
+
76
+ cdef inline object extend(object buf, const char* at, size_t length):
77
+ cdef Py_ssize_t s
78
+ cdef char* ptr
79
+ s = PyByteArray_Size(buf)
80
+ PyByteArray_Resize(buf, s + length)
81
+ ptr = PyByteArray_AsString(buf)
82
+ memcpy(ptr + s, at, length)
83
+
84
+
85
+ DEF METHODS_COUNT = 46;
86
+
87
+ cdef list _http_method = []
88
+
89
+ for i in range(METHODS_COUNT):
90
+ _http_method.append(
91
+ cparser.llhttp_method_name(<cparser.llhttp_method_t> i).decode('ascii'))
92
+
93
+
94
+ cdef inline str http_method_str(int i):
95
+ if i < METHODS_COUNT:
96
+ return <str>_http_method[i]
97
+ else:
98
+ return "<unknown>"
99
+
100
+ cdef inline object find_header(bytes raw_header):
101
+ cdef Py_ssize_t size
102
+ cdef char *buf
103
+ cdef int idx
104
+ PyBytes_AsStringAndSize(raw_header, &buf, &size)
105
+ idx = _find_header.find_header(buf, size)
106
+ if idx == -1:
107
+ return raw_header.decode('utf-8', 'surrogateescape')
108
+ return headers[idx]
109
+
110
+
111
+ @cython.freelist(DEFAULT_FREELIST_SIZE)
112
+ cdef class RawRequestMessage:
113
+ cdef readonly str method
114
+ cdef readonly str path
115
+ cdef readonly object version # HttpVersion
116
+ cdef readonly object headers # CIMultiDict
117
+ cdef readonly object raw_headers # tuple
118
+ cdef readonly object should_close
119
+ cdef readonly object compression
120
+ cdef readonly object upgrade
121
+ cdef readonly object chunked
122
+ cdef readonly object url # yarl.URL
123
+
124
+ def __init__(self, method, path, version, headers, raw_headers,
125
+ should_close, compression, upgrade, chunked, url):
126
+ self.method = method
127
+ self.path = path
128
+ self.version = version
129
+ self.headers = headers
130
+ self.raw_headers = raw_headers
131
+ self.should_close = should_close
132
+ self.compression = compression
133
+ self.upgrade = upgrade
134
+ self.chunked = chunked
135
+ self.url = url
136
+
137
+ def __repr__(self):
138
+ info = []
139
+ info.append(("method", self.method))
140
+ info.append(("path", self.path))
141
+ info.append(("version", self.version))
142
+ info.append(("headers", self.headers))
143
+ info.append(("raw_headers", self.raw_headers))
144
+ info.append(("should_close", self.should_close))
145
+ info.append(("compression", self.compression))
146
+ info.append(("upgrade", self.upgrade))
147
+ info.append(("chunked", self.chunked))
148
+ info.append(("url", self.url))
149
+ sinfo = ', '.join(name + '=' + repr(val) for name, val in info)
150
+ return '<RawRequestMessage(' + sinfo + ')>'
151
+
152
+ def _replace(self, **dct):
153
+ cdef RawRequestMessage ret
154
+ ret = _new_request_message(self.method,
155
+ self.path,
156
+ self.version,
157
+ self.headers,
158
+ self.raw_headers,
159
+ self.should_close,
160
+ self.compression,
161
+ self.upgrade,
162
+ self.chunked,
163
+ self.url)
164
+ if "method" in dct:
165
+ ret.method = dct["method"]
166
+ if "path" in dct:
167
+ ret.path = dct["path"]
168
+ if "version" in dct:
169
+ ret.version = dct["version"]
170
+ if "headers" in dct:
171
+ ret.headers = dct["headers"]
172
+ if "raw_headers" in dct:
173
+ ret.raw_headers = dct["raw_headers"]
174
+ if "should_close" in dct:
175
+ ret.should_close = dct["should_close"]
176
+ if "compression" in dct:
177
+ ret.compression = dct["compression"]
178
+ if "upgrade" in dct:
179
+ ret.upgrade = dct["upgrade"]
180
+ if "chunked" in dct:
181
+ ret.chunked = dct["chunked"]
182
+ if "url" in dct:
183
+ ret.url = dct["url"]
184
+ return ret
185
+
186
+ cdef _new_request_message(str method,
187
+ str path,
188
+ object version,
189
+ object headers,
190
+ object raw_headers,
191
+ bint should_close,
192
+ object compression,
193
+ bint upgrade,
194
+ bint chunked,
195
+ object url):
196
+ cdef RawRequestMessage ret
197
+ ret = RawRequestMessage.__new__(RawRequestMessage)
198
+ ret.method = method
199
+ ret.path = path
200
+ ret.version = version
201
+ ret.headers = headers
202
+ ret.raw_headers = raw_headers
203
+ ret.should_close = should_close
204
+ ret.compression = compression
205
+ ret.upgrade = upgrade
206
+ ret.chunked = chunked
207
+ ret.url = url
208
+ return ret
209
+
210
+
211
+ @cython.freelist(DEFAULT_FREELIST_SIZE)
212
+ cdef class RawResponseMessage:
213
+ cdef readonly object version # HttpVersion
214
+ cdef readonly int code
215
+ cdef readonly str reason
216
+ cdef readonly object headers # CIMultiDict
217
+ cdef readonly object raw_headers # tuple
218
+ cdef readonly object should_close
219
+ cdef readonly object compression
220
+ cdef readonly object upgrade
221
+ cdef readonly object chunked
222
+
223
+ def __init__(self, version, code, reason, headers, raw_headers,
224
+ should_close, compression, upgrade, chunked):
225
+ self.version = version
226
+ self.code = code
227
+ self.reason = reason
228
+ self.headers = headers
229
+ self.raw_headers = raw_headers
230
+ self.should_close = should_close
231
+ self.compression = compression
232
+ self.upgrade = upgrade
233
+ self.chunked = chunked
234
+
235
+ def __repr__(self):
236
+ info = []
237
+ info.append(("version", self.version))
238
+ info.append(("code", self.code))
239
+ info.append(("reason", self.reason))
240
+ info.append(("headers", self.headers))
241
+ info.append(("raw_headers", self.raw_headers))
242
+ info.append(("should_close", self.should_close))
243
+ info.append(("compression", self.compression))
244
+ info.append(("upgrade", self.upgrade))
245
+ info.append(("chunked", self.chunked))
246
+ sinfo = ', '.join(name + '=' + repr(val) for name, val in info)
247
+ return '<RawResponseMessage(' + sinfo + ')>'
248
+
249
+
250
+ cdef _new_response_message(object version,
251
+ int code,
252
+ str reason,
253
+ object headers,
254
+ object raw_headers,
255
+ bint should_close,
256
+ object compression,
257
+ bint upgrade,
258
+ bint chunked):
259
+ cdef RawResponseMessage ret
260
+ ret = RawResponseMessage.__new__(RawResponseMessage)
261
+ ret.version = version
262
+ ret.code = code
263
+ ret.reason = reason
264
+ ret.headers = headers
265
+ ret.raw_headers = raw_headers
266
+ ret.should_close = should_close
267
+ ret.compression = compression
268
+ ret.upgrade = upgrade
269
+ ret.chunked = chunked
270
+ return ret
271
+
272
+
273
+ @cython.internal
274
+ cdef class HttpParser:
275
+
276
+ cdef:
277
+ cparser.llhttp_t* _cparser
278
+ cparser.llhttp_settings_t* _csettings
279
+
280
+ bytes _raw_name
281
+ object _name
282
+ bytes _raw_value
283
+ bint _has_value
284
+
285
+ object _protocol
286
+ object _loop
287
+ object _timer
288
+
289
+ size_t _max_line_size
290
+ size_t _max_field_size
291
+ size_t _max_headers
292
+ bint _response_with_body
293
+ bint _read_until_eof
294
+
295
+ bint _started
296
+ object _url
297
+ bytearray _buf
298
+ str _path
299
+ str _reason
300
+ list _headers
301
+ list _raw_headers
302
+ bint _upgraded
303
+ list _messages
304
+ object _payload
305
+ bint _payload_error
306
+ object _payload_exception
307
+ object _last_error
308
+ bint _auto_decompress
309
+ int _limit
310
+
311
+ str _content_encoding
312
+
313
+ Py_buffer py_buf
314
+
315
+ def __cinit__(self):
316
+ self._cparser = <cparser.llhttp_t*> \
317
+ PyMem_Malloc(sizeof(cparser.llhttp_t))
318
+ if self._cparser is NULL:
319
+ raise MemoryError()
320
+
321
+ self._csettings = <cparser.llhttp_settings_t*> \
322
+ PyMem_Malloc(sizeof(cparser.llhttp_settings_t))
323
+ if self._csettings is NULL:
324
+ raise MemoryError()
325
+
326
+ def __dealloc__(self):
327
+ PyMem_Free(self._cparser)
328
+ PyMem_Free(self._csettings)
329
+
330
+ cdef _init(
331
+ self, cparser.llhttp_type mode,
332
+ object protocol, object loop, int limit,
333
+ object timer=None,
334
+ size_t max_line_size=8190, size_t max_headers=32768,
335
+ size_t max_field_size=8190, payload_exception=None,
336
+ bint response_with_body=True, bint read_until_eof=False,
337
+ bint auto_decompress=True,
338
+ ):
339
+ cparser.llhttp_settings_init(self._csettings)
340
+ cparser.llhttp_init(self._cparser, mode, self._csettings)
341
+ self._cparser.data = <void*>self
342
+ self._cparser.content_length = 0
343
+
344
+ self._protocol = protocol
345
+ self._loop = loop
346
+ self._timer = timer
347
+
348
+ self._buf = bytearray()
349
+ self._payload = None
350
+ self._payload_error = 0
351
+ self._payload_exception = payload_exception
352
+ self._messages = []
353
+
354
+ self._raw_name = EMPTY_BYTES
355
+ self._raw_value = EMPTY_BYTES
356
+ self._has_value = False
357
+
358
+ self._max_line_size = max_line_size
359
+ self._max_headers = max_headers
360
+ self._max_field_size = max_field_size
361
+ self._response_with_body = response_with_body
362
+ self._read_until_eof = read_until_eof
363
+ self._upgraded = False
364
+ self._auto_decompress = auto_decompress
365
+ self._content_encoding = None
366
+
367
+ self._csettings.on_url = cb_on_url
368
+ self._csettings.on_status = cb_on_status
369
+ self._csettings.on_header_field = cb_on_header_field
370
+ self._csettings.on_header_value = cb_on_header_value
371
+ self._csettings.on_headers_complete = cb_on_headers_complete
372
+ self._csettings.on_body = cb_on_body
373
+ self._csettings.on_message_begin = cb_on_message_begin
374
+ self._csettings.on_message_complete = cb_on_message_complete
375
+ self._csettings.on_chunk_header = cb_on_chunk_header
376
+ self._csettings.on_chunk_complete = cb_on_chunk_complete
377
+
378
+ self._last_error = None
379
+ self._limit = limit
380
+
381
+ cdef _process_header(self):
382
+ cdef str value
383
+ if self._raw_name is not EMPTY_BYTES:
384
+ name = find_header(self._raw_name)
385
+ value = self._raw_value.decode('utf-8', 'surrogateescape')
386
+
387
+ self._headers.append((name, value))
388
+
389
+ if name is CONTENT_ENCODING:
390
+ self._content_encoding = value
391
+
392
+ self._has_value = False
393
+ self._raw_headers.append((self._raw_name, self._raw_value))
394
+ self._raw_name = EMPTY_BYTES
395
+ self._raw_value = EMPTY_BYTES
396
+
397
+ cdef _on_header_field(self, char* at, size_t length):
398
+ if self._has_value:
399
+ self._process_header()
400
+
401
+ if self._raw_name is EMPTY_BYTES:
402
+ self._raw_name = at[:length]
403
+ else:
404
+ self._raw_name += at[:length]
405
+
406
+ cdef _on_header_value(self, char* at, size_t length):
407
+ if self._raw_value is EMPTY_BYTES:
408
+ self._raw_value = at[:length]
409
+ else:
410
+ self._raw_value += at[:length]
411
+ self._has_value = True
412
+
413
+ cdef _on_headers_complete(self):
414
+ self._process_header()
415
+
416
+ should_close = not cparser.llhttp_should_keep_alive(self._cparser)
417
+ upgrade = self._cparser.upgrade
418
+ chunked = self._cparser.flags & cparser.F_CHUNKED
419
+
420
+ raw_headers = tuple(self._raw_headers)
421
+ headers = CIMultiDictProxy(CIMultiDict(self._headers))
422
+
423
+ if self._cparser.type == cparser.HTTP_REQUEST:
424
+ allowed = upgrade and headers.get("upgrade", "").lower() in ALLOWED_UPGRADES
425
+ if allowed or self._cparser.method == cparser.HTTP_CONNECT:
426
+ self._upgraded = True
427
+ else:
428
+ if upgrade and self._cparser.status_code == 101:
429
+ self._upgraded = True
430
+
431
+ # do not support old websocket spec
432
+ if SEC_WEBSOCKET_KEY1 in headers:
433
+ raise InvalidHeader(SEC_WEBSOCKET_KEY1)
434
+
435
+ encoding = None
436
+ enc = self._content_encoding
437
+ if enc is not None:
438
+ self._content_encoding = None
439
+ enc = enc.lower()
440
+ if enc in ('gzip', 'deflate', 'br'):
441
+ encoding = enc
442
+
443
+ if self._cparser.type == cparser.HTTP_REQUEST:
444
+ method = http_method_str(self._cparser.method)
445
+ msg = _new_request_message(
446
+ method, self._path,
447
+ self.http_version(), headers, raw_headers,
448
+ should_close, encoding, upgrade, chunked, self._url)
449
+ else:
450
+ msg = _new_response_message(
451
+ self.http_version(), self._cparser.status_code, self._reason,
452
+ headers, raw_headers, should_close, encoding,
453
+ upgrade, chunked)
454
+
455
+ if (
456
+ ULLONG_MAX > self._cparser.content_length > 0 or chunked or
457
+ self._cparser.method == cparser.HTTP_CONNECT or
458
+ (self._cparser.status_code >= 199 and
459
+ self._cparser.content_length == 0 and
460
+ self._read_until_eof)
461
+ ):
462
+ payload = StreamReader(
463
+ self._protocol, timer=self._timer, loop=self._loop,
464
+ limit=self._limit)
465
+ else:
466
+ payload = EMPTY_PAYLOAD
467
+
468
+ self._payload = payload
469
+ if encoding is not None and self._auto_decompress:
470
+ self._payload = DeflateBuffer(payload, encoding)
471
+
472
+ if not self._response_with_body:
473
+ payload = EMPTY_PAYLOAD
474
+
475
+ self._messages.append((msg, payload))
476
+
477
+ cdef _on_message_complete(self):
478
+ self._payload.feed_eof()
479
+ self._payload = None
480
+
481
+ cdef _on_chunk_header(self):
482
+ self._payload.begin_http_chunk_receiving()
483
+
484
+ cdef _on_chunk_complete(self):
485
+ self._payload.end_http_chunk_receiving()
486
+
487
+ cdef object _on_status_complete(self):
488
+ pass
489
+
490
+ cdef inline http_version(self):
491
+ cdef cparser.llhttp_t* parser = self._cparser
492
+
493
+ if parser.http_major == 1:
494
+ if parser.http_minor == 0:
495
+ return HttpVersion10
496
+ elif parser.http_minor == 1:
497
+ return HttpVersion11
498
+
499
+ return HttpVersion(parser.http_major, parser.http_minor)
500
+
501
+ ### Public API ###
502
+
503
+ def feed_eof(self):
504
+ cdef bytes desc
505
+
506
+ if self._payload is not None:
507
+ if self._cparser.flags & cparser.F_CHUNKED:
508
+ raise TransferEncodingError(
509
+ "Not enough data for satisfy transfer length header.")
510
+ elif self._cparser.flags & cparser.F_CONTENT_LENGTH:
511
+ raise ContentLengthError(
512
+ "Not enough data for satisfy content length header.")
513
+ elif cparser.llhttp_get_errno(self._cparser) != cparser.HPE_OK:
514
+ desc = cparser.llhttp_get_error_reason(self._cparser)
515
+ raise PayloadEncodingError(desc.decode('latin-1'))
516
+ else:
517
+ self._payload.feed_eof()
518
+ elif self._started:
519
+ self._on_headers_complete()
520
+ if self._messages:
521
+ return self._messages[-1][0]
522
+
523
+ def feed_data(self, data):
524
+ cdef:
525
+ size_t data_len
526
+ size_t nb
527
+ cdef cparser.llhttp_errno_t errno
528
+
529
+ PyObject_GetBuffer(data, &self.py_buf, PyBUF_SIMPLE)
530
+ data_len = <size_t>self.py_buf.len
531
+
532
+ errno = cparser.llhttp_execute(
533
+ self._cparser,
534
+ <char*>self.py_buf.buf,
535
+ data_len)
536
+
537
+ if errno is cparser.HPE_PAUSED_UPGRADE:
538
+ cparser.llhttp_resume_after_upgrade(self._cparser)
539
+
540
+ nb = cparser.llhttp_get_error_pos(self._cparser) - <char*>self.py_buf.buf
541
+
542
+ PyBuffer_Release(&self.py_buf)
543
+
544
+ if errno not in (cparser.HPE_OK, cparser.HPE_PAUSED_UPGRADE):
545
+ if self._payload_error == 0:
546
+ if self._last_error is not None:
547
+ ex = self._last_error
548
+ self._last_error = None
549
+ else:
550
+ after = cparser.llhttp_get_error_pos(self._cparser)
551
+ before = data[:after - <char*>self.py_buf.buf]
552
+ after_b = after.split(b"\r\n", 1)[0]
553
+ before = before.rsplit(b"\r\n", 1)[-1]
554
+ data = before + after_b
555
+ pointer = " " * (len(repr(before))-1) + "^"
556
+ ex = parser_error_from_errno(self._cparser, data, pointer)
557
+ self._payload = None
558
+ raise ex
559
+
560
+ if self._messages:
561
+ messages = self._messages
562
+ self._messages = []
563
+ else:
564
+ messages = ()
565
+
566
+ if self._upgraded:
567
+ return messages, True, data[nb:]
568
+ else:
569
+ return messages, False, b""
570
+
571
+ def set_upgraded(self, val):
572
+ self._upgraded = val
573
+
574
+
575
+ cdef class HttpRequestParser(HttpParser):
576
+
577
+ def __init__(
578
+ self, protocol, loop, int limit, timer=None,
579
+ size_t max_line_size=8190, size_t max_headers=32768,
580
+ size_t max_field_size=8190, payload_exception=None,
581
+ bint response_with_body=True, bint read_until_eof=False,
582
+ bint auto_decompress=True,
583
+ ):
584
+ self._init(cparser.HTTP_REQUEST, protocol, loop, limit, timer,
585
+ max_line_size, max_headers, max_field_size,
586
+ payload_exception, response_with_body, read_until_eof,
587
+ auto_decompress)
588
+
589
+ cdef object _on_status_complete(self):
590
+ cdef int idx1, idx2
591
+ if not self._buf:
592
+ return
593
+ self._path = self._buf.decode('utf-8', 'surrogateescape')
594
+ try:
595
+ idx3 = len(self._path)
596
+ if self._cparser.method == cparser.HTTP_CONNECT:
597
+ # authority-form,
598
+ # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.3
599
+ self._url = URL.build(authority=self._path, encoded=True)
600
+ elif idx3 > 1 and self._path[0] == '/':
601
+ # origin-form,
602
+ # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1
603
+ idx1 = self._path.find("?")
604
+ if idx1 == -1:
605
+ query = ""
606
+ idx2 = self._path.find("#")
607
+ if idx2 == -1:
608
+ path = self._path
609
+ fragment = ""
610
+ else:
611
+ path = self._path[0: idx2]
612
+ fragment = self._path[idx2+1:]
613
+
614
+ else:
615
+ path = self._path[0:idx1]
616
+ idx1 += 1
617
+ idx2 = self._path.find("#", idx1+1)
618
+ if idx2 == -1:
619
+ query = self._path[idx1:]
620
+ fragment = ""
621
+ else:
622
+ query = self._path[idx1: idx2]
623
+ fragment = self._path[idx2+1:]
624
+
625
+ self._url = URL.build(
626
+ path=path,
627
+ query_string=query,
628
+ fragment=fragment,
629
+ encoded=True,
630
+ )
631
+ else:
632
+ # absolute-form for proxy maybe,
633
+ # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.2
634
+ self._url = URL(self._path, encoded=True)
635
+ finally:
636
+ PyByteArray_Resize(self._buf, 0)
637
+
638
+
639
+ cdef class HttpResponseParser(HttpParser):
640
+
641
+ def __init__(
642
+ self, protocol, loop, int limit, timer=None,
643
+ size_t max_line_size=8190, size_t max_headers=32768,
644
+ size_t max_field_size=8190, payload_exception=None,
645
+ bint response_with_body=True, bint read_until_eof=False,
646
+ bint auto_decompress=True
647
+ ):
648
+ self._init(cparser.HTTP_RESPONSE, protocol, loop, limit, timer,
649
+ max_line_size, max_headers, max_field_size,
650
+ payload_exception, response_with_body, read_until_eof,
651
+ auto_decompress)
652
+ # Use strict parsing on dev mode, so users are warned about broken servers.
653
+ if not DEBUG:
654
+ cparser.llhttp_set_lenient_headers(self._cparser, 1)
655
+ cparser.llhttp_set_lenient_optional_cr_before_lf(self._cparser, 1)
656
+ cparser.llhttp_set_lenient_spaces_after_chunk_size(self._cparser, 1)
657
+
658
+ cdef object _on_status_complete(self):
659
+ if self._buf:
660
+ self._reason = self._buf.decode('utf-8', 'surrogateescape')
661
+ PyByteArray_Resize(self._buf, 0)
662
+ else:
663
+ self._reason = self._reason or ''
664
+
665
+ cdef int cb_on_message_begin(cparser.llhttp_t* parser) except -1:
666
+ cdef HttpParser pyparser = <HttpParser>parser.data
667
+
668
+ pyparser._started = True
669
+ pyparser._headers = []
670
+ pyparser._raw_headers = []
671
+ PyByteArray_Resize(pyparser._buf, 0)
672
+ pyparser._path = None
673
+ pyparser._reason = None
674
+ return 0
675
+
676
+
677
+ cdef int cb_on_url(cparser.llhttp_t* parser,
678
+ const char *at, size_t length) except -1:
679
+ cdef HttpParser pyparser = <HttpParser>parser.data
680
+ try:
681
+ if length > pyparser._max_line_size:
682
+ raise LineTooLong(
683
+ 'Status line is too long', pyparser._max_line_size, length)
684
+ extend(pyparser._buf, at, length)
685
+ except BaseException as ex:
686
+ pyparser._last_error = ex
687
+ return -1
688
+ else:
689
+ return 0
690
+
691
+
692
+ cdef int cb_on_status(cparser.llhttp_t* parser,
693
+ const char *at, size_t length) except -1:
694
+ cdef HttpParser pyparser = <HttpParser>parser.data
695
+ cdef str reason
696
+ try:
697
+ if length > pyparser._max_line_size:
698
+ raise LineTooLong(
699
+ 'Status line is too long', pyparser._max_line_size, length)
700
+ extend(pyparser._buf, at, length)
701
+ except BaseException as ex:
702
+ pyparser._last_error = ex
703
+ return -1
704
+ else:
705
+ return 0
706
+
707
+
708
+ cdef int cb_on_header_field(cparser.llhttp_t* parser,
709
+ const char *at, size_t length) except -1:
710
+ cdef HttpParser pyparser = <HttpParser>parser.data
711
+ cdef Py_ssize_t size
712
+ try:
713
+ pyparser._on_status_complete()
714
+ size = len(pyparser._raw_name) + length
715
+ if size > pyparser._max_field_size:
716
+ raise LineTooLong(
717
+ 'Header name is too long', pyparser._max_field_size, size)
718
+ pyparser._on_header_field(at, length)
719
+ except BaseException as ex:
720
+ pyparser._last_error = ex
721
+ return -1
722
+ else:
723
+ return 0
724
+
725
+
726
+ cdef int cb_on_header_value(cparser.llhttp_t* parser,
727
+ const char *at, size_t length) except -1:
728
+ cdef HttpParser pyparser = <HttpParser>parser.data
729
+ cdef Py_ssize_t size
730
+ try:
731
+ size = len(pyparser._raw_value) + length
732
+ if size > pyparser._max_field_size:
733
+ raise LineTooLong(
734
+ 'Header value is too long', pyparser._max_field_size, size)
735
+ pyparser._on_header_value(at, length)
736
+ except BaseException as ex:
737
+ pyparser._last_error = ex
738
+ return -1
739
+ else:
740
+ return 0
741
+
742
+
743
+ cdef int cb_on_headers_complete(cparser.llhttp_t* parser) except -1:
744
+ cdef HttpParser pyparser = <HttpParser>parser.data
745
+ try:
746
+ pyparser._on_status_complete()
747
+ pyparser._on_headers_complete()
748
+ except BaseException as exc:
749
+ pyparser._last_error = exc
750
+ return -1
751
+ else:
752
+ if pyparser._upgraded or pyparser._cparser.method == cparser.HTTP_CONNECT:
753
+ return 2
754
+ else:
755
+ return 0
756
+
757
+
758
+ cdef int cb_on_body(cparser.llhttp_t* parser,
759
+ const char *at, size_t length) except -1:
760
+ cdef HttpParser pyparser = <HttpParser>parser.data
761
+ cdef bytes body = at[:length]
762
+ try:
763
+ pyparser._payload.feed_data(body, length)
764
+ except BaseException as underlying_exc:
765
+ reraised_exc = underlying_exc
766
+ if pyparser._payload_exception is not None:
767
+ reraised_exc = pyparser._payload_exception(str(underlying_exc))
768
+
769
+ set_exception(pyparser._payload, reraised_exc, underlying_exc)
770
+
771
+ pyparser._payload_error = 1
772
+ return -1
773
+ else:
774
+ return 0
775
+
776
+
777
+ cdef int cb_on_message_complete(cparser.llhttp_t* parser) except -1:
778
+ cdef HttpParser pyparser = <HttpParser>parser.data
779
+ try:
780
+ pyparser._started = False
781
+ pyparser._on_message_complete()
782
+ except BaseException as exc:
783
+ pyparser._last_error = exc
784
+ return -1
785
+ else:
786
+ return 0
787
+
788
+
789
+ cdef int cb_on_chunk_header(cparser.llhttp_t* parser) except -1:
790
+ cdef HttpParser pyparser = <HttpParser>parser.data
791
+ try:
792
+ pyparser._on_chunk_header()
793
+ except BaseException as exc:
794
+ pyparser._last_error = exc
795
+ return -1
796
+ else:
797
+ return 0
798
+
799
+
800
+ cdef int cb_on_chunk_complete(cparser.llhttp_t* parser) except -1:
801
+ cdef HttpParser pyparser = <HttpParser>parser.data
802
+ try:
803
+ pyparser._on_chunk_complete()
804
+ except BaseException as exc:
805
+ pyparser._last_error = exc
806
+ return -1
807
+ else:
808
+ return 0
809
+
810
+
811
+ cdef parser_error_from_errno(cparser.llhttp_t* parser, data, pointer):
812
+ cdef cparser.llhttp_errno_t errno = cparser.llhttp_get_errno(parser)
813
+ cdef bytes desc = cparser.llhttp_get_error_reason(parser)
814
+
815
+ err_msg = "{}:\n\n {!r}\n {}".format(desc.decode("latin-1"), data, pointer)
816
+
817
+ if errno in {cparser.HPE_CB_MESSAGE_BEGIN,
818
+ cparser.HPE_CB_HEADERS_COMPLETE,
819
+ cparser.HPE_CB_MESSAGE_COMPLETE,
820
+ cparser.HPE_CB_CHUNK_HEADER,
821
+ cparser.HPE_CB_CHUNK_COMPLETE,
822
+ cparser.HPE_INVALID_CONSTANT,
823
+ cparser.HPE_INVALID_HEADER_TOKEN,
824
+ cparser.HPE_INVALID_CONTENT_LENGTH,
825
+ cparser.HPE_INVALID_CHUNK_SIZE,
826
+ cparser.HPE_INVALID_EOF_STATE,
827
+ cparser.HPE_INVALID_TRANSFER_ENCODING}:
828
+ return BadHttpMessage(err_msg)
829
+ elif errno == cparser.HPE_INVALID_METHOD:
830
+ return BadHttpMethod(error=err_msg)
831
+ elif errno in {cparser.HPE_INVALID_STATUS,
832
+ cparser.HPE_INVALID_VERSION}:
833
+ return BadStatusLine(error=err_msg)
834
+ elif errno == cparser.HPE_INVALID_URL:
835
+ return InvalidURLError(err_msg)
836
+
837
+ return BadHttpMessage(err_msg)
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_http_writer.pyx ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from cpython.bytes cimport PyBytes_FromStringAndSize
2
+ from cpython.exc cimport PyErr_NoMemory
3
+ from cpython.mem cimport PyMem_Free, PyMem_Malloc, PyMem_Realloc
4
+ from cpython.object cimport PyObject_Str
5
+ from libc.stdint cimport uint8_t, uint64_t
6
+ from libc.string cimport memcpy
7
+
8
+ from multidict import istr
9
+
10
+ DEF BUF_SIZE = 16 * 1024 # 16KiB
11
+ cdef char BUFFER[BUF_SIZE]
12
+
13
+ cdef object _istr = istr
14
+
15
+
16
+ # ----------------- writer ---------------------------
17
+
18
+ cdef struct Writer:
19
+ char *buf
20
+ Py_ssize_t size
21
+ Py_ssize_t pos
22
+
23
+
24
+ cdef inline void _init_writer(Writer* writer):
25
+ writer.buf = &BUFFER[0]
26
+ writer.size = BUF_SIZE
27
+ writer.pos = 0
28
+
29
+
30
+ cdef inline void _release_writer(Writer* writer):
31
+ if writer.buf != BUFFER:
32
+ PyMem_Free(writer.buf)
33
+
34
+
35
+ cdef inline int _write_byte(Writer* writer, uint8_t ch):
36
+ cdef char * buf
37
+ cdef Py_ssize_t size
38
+
39
+ if writer.pos == writer.size:
40
+ # reallocate
41
+ size = writer.size + BUF_SIZE
42
+ if writer.buf == BUFFER:
43
+ buf = <char*>PyMem_Malloc(size)
44
+ if buf == NULL:
45
+ PyErr_NoMemory()
46
+ return -1
47
+ memcpy(buf, writer.buf, writer.size)
48
+ else:
49
+ buf = <char*>PyMem_Realloc(writer.buf, size)
50
+ if buf == NULL:
51
+ PyErr_NoMemory()
52
+ return -1
53
+ writer.buf = buf
54
+ writer.size = size
55
+ writer.buf[writer.pos] = <char>ch
56
+ writer.pos += 1
57
+ return 0
58
+
59
+
60
+ cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol):
61
+ cdef uint64_t utf = <uint64_t> symbol
62
+
63
+ if utf < 0x80:
64
+ return _write_byte(writer, <uint8_t>utf)
65
+ elif utf < 0x800:
66
+ if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
67
+ return -1
68
+ return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
69
+ elif 0xD800 <= utf <= 0xDFFF:
70
+ # surogate pair, ignored
71
+ return 0
72
+ elif utf < 0x10000:
73
+ if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
74
+ return -1
75
+ if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
76
+ return -1
77
+ return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
78
+ elif utf > 0x10FFFF:
79
+ # symbol is too large
80
+ return 0
81
+ else:
82
+ if _write_byte(writer, <uint8_t>(0xf0 | (utf >> 18))) < 0:
83
+ return -1
84
+ if _write_byte(writer,
85
+ <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
86
+ return -1
87
+ if _write_byte(writer,
88
+ <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
89
+ return -1
90
+ return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
91
+
92
+
93
+ cdef inline int _write_str(Writer* writer, str s):
94
+ cdef Py_UCS4 ch
95
+ for ch in s:
96
+ if _write_utf8(writer, ch) < 0:
97
+ return -1
98
+
99
+
100
+ # --------------- _serialize_headers ----------------------
101
+
102
+ cdef str to_str(object s):
103
+ if type(s) is str:
104
+ return <str>s
105
+ elif type(s) is _istr:
106
+ return PyObject_Str(s)
107
+ elif not isinstance(s, str):
108
+ raise TypeError("Cannot serialize non-str key {!r}".format(s))
109
+ else:
110
+ return str(s)
111
+
112
+
113
+
114
+ def _serialize_headers(str status_line, headers):
115
+ cdef Writer writer
116
+ cdef object key
117
+ cdef object val
118
+ cdef bytes ret
119
+ cdef str key_str
120
+ cdef str val_str
121
+
122
+ _init_writer(&writer)
123
+
124
+ try:
125
+ if _write_str(&writer, status_line) < 0:
126
+ raise
127
+ if _write_byte(&writer, b'\r') < 0:
128
+ raise
129
+ if _write_byte(&writer, b'\n') < 0:
130
+ raise
131
+
132
+ for key, val in headers.items():
133
+ key_str = to_str(key)
134
+ val_str = to_str(val)
135
+
136
+ if "\r" in key_str or "\n" in key_str or "\r" in val_str or "\n" in val_str:
137
+ raise ValueError(
138
+ "Newline or carriage return character detected in HTTP status message or "
139
+ "header. This is a potential security issue."
140
+ )
141
+
142
+ if _write_str(&writer, key_str) < 0:
143
+ raise
144
+ if _write_byte(&writer, b':') < 0:
145
+ raise
146
+ if _write_byte(&writer, b' ') < 0:
147
+ raise
148
+ if _write_str(&writer, val_str) < 0:
149
+ raise
150
+ if _write_byte(&writer, b'\r') < 0:
151
+ raise
152
+ if _write_byte(&writer, b'\n') < 0:
153
+ raise
154
+
155
+ if _write_byte(&writer, b'\r') < 0:
156
+ raise
157
+ if _write_byte(&writer, b'\n') < 0:
158
+ raise
159
+
160
+ return PyBytes_FromStringAndSize(writer.buf, writer.pos)
161
+ finally:
162
+ _release_writer(&writer)
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/mask.pxd.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ b01999d409b29bd916e067bc963d5f2d9ee63cfc9ae0bccb769910131417bf93 /home/runner/work/aiohttp/aiohttp/aiohttp/_websocket/mask.pxd
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/mask.pyx.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ 0478ceb55d0ed30ef1a7da742cd003449bc69a07cf9fdb06789bd2b347cbfffe /home/runner/work/aiohttp/aiohttp/aiohttp/_websocket/mask.pyx
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/.hash/reader_c.pxd.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ f6b3160a9002d639e0eff82da8b8d196a42ff6aed490e9faded2107eada4f067 /home/runner/work/aiohttp/aiohttp/aiohttp/_websocket/reader_c.pxd
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """WebSocket protocol versions 13 and 8."""
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (290 Bytes). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/helpers.cpython-311.pyc ADDED
Binary file (6.98 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/models.cpython-311.pyc ADDED
Binary file (4.02 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader.cpython-311.pyc ADDED
Binary file (962 Bytes). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader_c.cpython-311.pyc ADDED
Binary file (18.3 kB). View file
 
.venv/lib/python3.11/site-packages/ray/_private/runtime_env/agent/thirdparty_files/aiohttp/_websocket/__pycache__/reader_py.cpython-311.pyc ADDED
Binary file (18.3 kB). View file