aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/gunicorn/http/parser.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/gunicorn/http/parser.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/gunicorn/http/parser.py')
-rw-r--r--.venv/lib/python3.12/site-packages/gunicorn/http/parser.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/gunicorn/http/parser.py b/.venv/lib/python3.12/site-packages/gunicorn/http/parser.py
new file mode 100644
index 00000000..5d689f06
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/gunicorn/http/parser.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -
+#
+# This file is part of gunicorn released under the MIT license.
+# See the NOTICE for more information.
+
+from gunicorn.http.message import Request
+from gunicorn.http.unreader import SocketUnreader, IterUnreader
+
+
+class Parser(object):
+
+ mesg_class = None
+
+ def __init__(self, cfg, source, source_addr):
+ self.cfg = cfg
+ if hasattr(source, "recv"):
+ self.unreader = SocketUnreader(source)
+ else:
+ self.unreader = IterUnreader(source)
+ self.mesg = None
+ self.source_addr = source_addr
+
+ # request counter (for keepalive connetions)
+ self.req_count = 0
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ # Stop if HTTP dictates a stop.
+ if self.mesg and self.mesg.should_close():
+ raise StopIteration()
+
+ # Discard any unread body of the previous message
+ if self.mesg:
+ data = self.mesg.body.read(8192)
+ while data:
+ data = self.mesg.body.read(8192)
+
+ # Parse the next request
+ self.req_count += 1
+ self.mesg = self.mesg_class(self.cfg, self.unreader, self.source_addr, self.req_count)
+ if not self.mesg:
+ raise StopIteration()
+ return self.mesg
+
+ next = __next__
+
+
+class RequestParser(Parser):
+
+ mesg_class = Request