| 143 | self.allowed_methods = [m.upper() for m in allowed_methods] |
| 144 | |
| 145 | def __call__(self, out, buf): |
| 146 | raw_data = yield from buf.waituntil(b' ', 12) |
| 147 | method = raw_data.decode('ascii', 'surrogateescape').strip() |
| 148 | |
| 149 | # method |
| 150 | method = method.upper() |
| 151 | if not METHRE.match(method): |
| 152 | raise errors.BadStatusLine(method) |
| 153 | |
| 154 | # allowed method |
| 155 | if self.allowed_methods and method not in self.allowed_methods: |
| 156 | raise errors.HttpMethodNotAllowed(message=method) |
| 157 | |
| 158 | out.feed_data(method, len(method)) |
| 159 | out.feed_eof() |
| 160 | |
| 161 | |
| 162 | class HttpRequestParser(HttpParser): |