<commit_before>import re

from .message import Request
from .util import normalize_line_endings

try:
    # Python 3
    from urllib.parse import urlparse
    from urllib.parse import parse_qs
    from urllib.parse import quote
except ImportError:
    # Python 2
    from urlparse import urlparse
    from urlparse import parse_qs
    from urllib import quote

RE_METHOD = """(?P<method>[A-Z]+)"""
RE_URI = """(?P<uri>[a-zA-Z0-9\-\/\.\_\:\?\#\[\]\@\!\$\&\=]+)"""


def _read_request_line_dict(line):
    # Return a dicionary containing information about the request.
    m = re.search(RE_METHOD + "\s+" + RE_URI, line)
    if m:
        return m.groupdict()
    m = re.search(RE_URI, line)
    if m:
        return m.groupdict()
    return None


class RequestParser:
    def __init__(self, settings, eol):
        self.settings = settings
        self.eol = eol
        self.request = None<commit_msg>Parse request line without using regular expressions.<commit_after>import re

from .message import Request
from .util import normalize_line_endings

try:
    # Python 3
    from urllib.parse import urlparse
    from urllib.parse import parse_qs
    from urllib.parse import quote
except ImportError:
    # Python 2
    from urlparse import urlparse
    from urlparse import parse_qs
    from urllib import quote


def _read_request_line_dict(line):
    """Return a dict containing the method and uri for a request line"""

    # Split the line into words.
    words = line.split(" ")
    method = "GET"
    # If the line contains only one word, assume the line is the URI.
    if len(words) == 1:
        uri = words[0]
    else:
        method = words[0]
        uri = words[1]

    return {
        "method": method,
        "uri": uri
    }


class RequestParser:
    def __init__(self, settings, eol):
        self.settings = settings
        self.eol = eol
        self.request = None
{'fraction_non_alphanumeric': 0.09836065573770492, 'fraction_numerical': 0.005288207297726071, 'mean_word_length': 2.6384615384615384, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1495964', 'n_tokens_mistral': 603, 'n_tokens_neox': 580, 'n_words': 194}