11from typing import Union , Any
2- from array import array
2+ from array import array
33from .protocol import HTTPProtocol
44
5-
6-
75class HttpParser :
8- def __init__ (self , protocol :Union [HTTPProtocol , Any ]) -> None :
6+ def __init__ (self , protocol : Union [HTTPProtocol , Any ]) -> None :
97 """
108 protocol -- a Python object with the following methods
119 (all optional):
@@ -24,15 +22,18 @@ class HttpParser:
2422 def get_http_version (self ) -> str :
2523 """Return an HTTP protocol version."""
2624 ...
25+
2726 def should_keep_alive (self ) -> bool :
2827 """Return ``True`` if keep-alive mode is preferred."""
2928 ...
29+
3030 def should_upgrade (self ) -> bool :
3131 """Return ``True`` if the parsed request is a valid Upgrade request.
32- The method exposes a flag set just before on_headers_complete.
33- Calling this method earlier will only yield `False`."""
32+ The method exposes a flag set just before on_headers_complete.
33+ Calling this method earlier will only yield `False`."""
3434 ...
35- def feed_data (self , data :Union [bytes , bytearray , memoryview , array ]) -> None :
35+
36+ def feed_data (self , data : Union [bytes , bytearray , memoryview , array ]) -> None :
3637 """Feed data to the parser.
3738
3839 Will eventually trigger callbacks on the ``protocol``
@@ -43,14 +44,12 @@ class HttpParser:
4344 set to the offset of the non-HTTP data in ``data``.
4445 """
4546
46-
4747class HttpRequestParser (HttpParser ):
4848 """Used for parsing http requests from the server's side"""
49-
49+
5050 def get_method (self ) -> bytes :
5151 """Return HTTP request method (GET, HEAD, etc)"""
5252
53-
5453class HttpResponseParser (HttpParser ):
5554 """Used for parsing http requests from the client's side"""
5655
0 commit comments