<commit_before>import codecs
from types import SimpleNamespace
import json as _json
import gzip
import zlib

from .encode_values import encode_strings


class Response:
    '''
    A response object supporting a range of methods and attribs
    for accessing the status line, header, cookies, history and
    body of a response.
    '''
    def __init__(self, encoding, cookies, status_code, **data):
        for name, value in data.items():
            setattr(self, name, value)
        self.encoding = encoding
        self.history = []
        self.cookies = cookies
        self.status_code = status_code

    def __repr__(self):
        # TODO: include the name of the response here
        # e.g. "201 Created" or "404 Not Found"
        # maybe a status_text attribute or something could be nice too?
        # requests has a status codes dictionary thingy, it can be used
        # like requests.status_codes.codes['NOT_FOUND']
        return "<asks response [%d]>"  % self.status_code

    def __iter__(self):
        for k, v in self.__dict__.items():
            yield k, v

    def _check_redirect(self):
        if 300 <= self.status_code < 400:
            if self.status_code in [301, 305]:
                # redirect / force GET / location
                return True, False, self.headers['Location']
            else:
                return True, True, self.headers['Location']
        else:
            return False, None, None

    def _guess_encoding(self):
        try:
            guess = self.headers['content-type'].split('=')[1]
            codecs.lookup(guess)
        # TODO: replace Exception with errors from first line
        except (Exception, LookupError):
            pass
        else:
            self.encoding = guess

    def _parse_cookies(self, host):
        cookie_pie = []
        for cookie in self.cookies:<commit_msg>fixing things<commit_after>import codecs
from types import SimpleNamespace
import json as _json
import gzip
import zlib


class Response:
    '''
    A response object supporting a range of methods and attribs
    for accessing the status line, header, cookies, history and
    body of a response.
    '''
    def __init__(self, encoding, cookies, status_code, **data):
        for name, value in data.items():
            setattr(self, name, value)
        self.encoding = encoding
        self.history = []
        self.cookies = cookies
        self.status_code = status_code

    def __repr__(self):
        # TODO: include the name of the response here
        # e.g. "201 Created" or "404 Not Found"
        # maybe a status_text attribute or something could be nice too?
        # requests has a status codes dictionary thingy, it can be used
        # like requests.status_codes.codes['NOT_FOUND']
        return "<Response %d at 0x%x>"  % (self.status_code, id(self))

    def __iter__(self):
        for k, v in self.__dict__.items():
            yield k, v

    def _check_redirect(self):
        if 300 <= self.status_code < 400:
            if self.status_code in [301, 305]:
                # redirect / force GET / location
                return True, False, self.headers['Location']
            else:
                return True, True, self.headers['Location']
        else:
            return False, None, None

    def _guess_encoding(self):
        try:
            guess = self.headers['content-type'].split('=')[1]
            codecs.lookup(guess)
        # TODO: replace Exception with errors from first line
        except (Exception, LookupError):
            pass
        else:
            self.encoding = guess

    def _parse_cookies(self, host):
        cookie_pie = []
        for cookie in self.cookies:
{'fraction_non_alphanumeric': 0.08680367766360195, 'fraction_numerical': 0.010546241211465657, 'mean_word_length': 2.118887015177066, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1517080', 'n_tokens_mistral': 1036, 'n_tokens_neox': 985, 'n_words': 352}