def parse_request(self):
self.command = None<EOL>self.request_version = version = self.default_request_version<EOL>self.close_connection = <NUM_LIT:1><EOL>requestline = self.raw_requestline<EOL>requestline = requestline.rstrip('<STR_LIT:\r\n>')<EOL>self.requestline = requestline<EOL>words = requestline.split()<EOL>if len(words) == <NUM_LIT:2>:<EOL><INDENT>command, version = words<EOL>if version[:<NUM_LIT:6>] != '<STR_LIT>':<EOL><INDENT>self.send_error("<STR_LIT>" % version)<EOL>return False<EOL><DEDENT>try:<EOL><INDENT>base_version_number = version.split('<STR_LIT:/>', <NUM_LIT:1>)[<NUM_LIT:1>]<EOL>version_number = base_version_number.split("<STR_LIT:.>")<EOL>if len(version_number) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError<EOL><DEDENT>version_number = int(version_number[<NUM_LIT:0>]), int(version_number[<NUM_LIT:1>])<EOL><DEDENT>except (ValueError, IndexError):<EOL><INDENT>self.send_error("<STR_LIT>" % version)<EOL>return False<EOL><DEDENT>if version_number >= (<NUM_LIT:1>, <NUM_LIT:6>):<EOL><INDENT>self.send_error(<EOL>"<STR_LIT>" % base_version_number)<EOL>return False<EOL><DEDENT><DEDENT>elif not words:<EOL><INDENT>return False<EOL><DEDENT>else:<EOL><INDENT>self.send_error("<STR_LIT>" % requestline)<EOL>return False<EOL><DEDENT>self.command, self.request_version = command, version<EOL>self.headers = self.MessageClass(self.rfile, <NUM_LIT:0>)<EOL>return True<EOL>
Parse the request