Skip to content

Commit

Permalink
droppped HttpPrefixParser #1590
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Kim committed Feb 8, 2017
1 parent 3e6bb84 commit 21b5679
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ CHANGES

1.4.0 (XXXX-XX-XX)
------------------

- Dropped: `aiohttp.protocol.HttpPrefixParser` #1590
26 changes: 1 addition & 25 deletions aiohttp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
__all__ = ('HttpMessage', 'Request', 'Response',
'HttpVersion', 'HttpVersion10', 'HttpVersion11',
'RawRequestMessage', 'RawResponseMessage',
'HttpPrefixParser', 'HttpRequestParser', 'HttpResponseParser',
'HttpPayloadParser')
'HttpRequestParser', 'HttpResponseParser', 'HttpPayloadParser')

ASCIISET = set(string.printable)
METHRE = re.compile('[A-Z0-9$-_.]+')
Expand Down Expand Up @@ -141,29 +140,6 @@ def parse_headers(self, lines):
return headers, raw_headers, close_conn, encoding


class HttpPrefixParser:
"""Waits for 'HTTP' prefix (non destructive)"""

def __init__(self, allowed_methods=()):
self.allowed_methods = [m.upper() for m in allowed_methods]

def __call__(self, out, buf):
raw_data = yield from buf.waituntil(b' ', 12)
method = raw_data.decode('ascii', 'surrogateescape').strip()

# method
method = method.upper()
if not METHRE.match(method):
raise errors.BadStatusLine(method)

# allowed method
if self.allowed_methods and method not in self.allowed_methods:
raise errors.HttpMethodNotAllowed(message=method)

out.feed_data(method, len(method))
out.feed_eof()


class HttpRequestParser(HttpParser):
"""Read request status line. Exception errors.BadStatusLine
could be raised in case of any errors in status line.
Expand Down

0 comments on commit 21b5679

Please sign in to comment.