<commit_before>from uuid import uuid4
from django.conf import settings

from .locals import set_cid, get_cid


class CidMiddleware(object):
    """
    Middleware class to extract the correlation id from incoming headers
    and add them to out going headers
    """

    def __init__(self):
        self.cid_header = getattr(settings, 'CID_HEADER', 'X_CORRELATION_ID')
        self.generate_cid = getattr(settings, 'CID_GENERATE', False)

    def process_request(self, request):
        cid = request.META.get(self.cid_header, None)
        if cid is None and self.generate_cid:
            cid = unicode(uuid4())
        request.correlation_id = cid
        set_cid(request.correlation_id)

    def process_response(self, request, response):
        cid = get_cid()
        if cid:
            response[self.cid_header] = cid<commit_msg>Switching to str instead of unicode<commit_after>from uuid import uuid4
from django.conf import settings

from .locals import set_cid, get_cid


class CidMiddleware(object):
    """
    Middleware class to extract the correlation id from incoming headers
    and add them to out going headers
    """

    def __init__(self):
        self.cid_header = getattr(settings, 'CID_HEADER', 'X_CORRELATION_ID')
        self.generate_cid = getattr(settings, 'CID_GENERATE', False)

    def process_request(self, request):
        cid = request.META.get(self.cid_header, None)
        if cid is None and self.generate_cid:
            cid = str(uuid4())
        request.correlation_id = cid
        set_cid(request.correlation_id)

    def process_response(self, request, response):
        cid = get_cid()
        if cid:
            response[self.cid_header] = cid
{'fraction_non_alphanumeric': 0.08490566037735849, 'fraction_numerical': 0.0023584905660377358, 'mean_word_length': 2.983568075117371, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '302298', 'n_tokens_mistral': 517, 'n_tokens_neox': 524, 'n_words': 142}