<commit_before>
class HTTPRequest:

    def doCreateXmlHTTPRequest(self):
        if JS("""typeof $wnd.XMLHttpRequest != 'undefined'"""):
            # IE7+, Mozilla, Safari, ...
           return JS("""new XMLHttpRequest()""")

        # Check for IE6/ActiveX
        try:
            res = JS("""new ActiveXObject("Msxml2.XMLHTTP")""")
            return res
        except:
            pass
        return None

    def asyncImpl(self, method, user, pwd, url, postData, handler,
                      returnxml, content_type=None, headers=None):
        if headers is None:
            headers = {}
        if user and pwd and not "Authorization" in headers:
            import base64
            headers["Authorization"] = 'Basic %s' % (base64.b64encode('%s:%s' % (user, pwd)))
        
        if postData is not None and not "Content-Length" in headers:
            headers["Content-Length"] = str(len(postData))
        if content_type is not None:
            headers["Content-Type"] = content_type
        if not "Content-Type" in headers:
            if returnxml:
                headers["Content-Type"] = "application/xml; charset=utf-8"
            else:
                headers["Content-Type"] = "text/plain; charset=utf-8"
        xmlHttp = self.doCreateXmlHTTPRequest()

        def onreadystatechange(evnt):
            global xmlHttp, handler
            if xmlHttp.readyState == 4:
                # For IE:
                JS("delete xmlHttp.onreadystatechange;")
                localHandler = handler
                status = xmlHttp.status
                if returnxml:
                    response = xmlHttp.responseXML
                else:
                    response = xmlHttp.responseText;
                handler = None
                xmlHttp = None
                if status == 200 or status == 0:
                    localHandler.onCompletion(response);
                else:
                    localHandler.onError(response, status);
        xmlHttp.onreadystatechange = onreadystatechange

        try:
            xmlHttp.open(method, url, True);
            for h in headers:<commit_msg>Fix for IE with onreadystate parameter<commit_after>
class HTTPRequest:

    def doCreateXmlHTTPRequest(self):
        if JS("""typeof $wnd.XMLHttpRequest != 'undefined'"""):
            # IE7+, Mozilla, Safari, ...
           return JS("""new XMLHttpRequest()""")

        # Check for IE6/ActiveX
        try:
            res = JS("""new ActiveXObject("Msxml2.XMLHTTP")""")
            return res
        except:
            pass
        return None

    def asyncImpl(self, method, user, pwd, url, postData, handler,
                      returnxml, content_type=None, headers=None):
        if headers is None:
            headers = {}
        if user and pwd and not "Authorization" in headers:
            import base64
            headers["Authorization"] = 'Basic %s' % (base64.b64encode('%s:%s' % (user, pwd)))
        
        if postData is not None and not "Content-Length" in headers:
            headers["Content-Length"] = str(len(postData))
        if content_type is not None:
            headers["Content-Type"] = content_type
        if not "Content-Type" in headers:
            if returnxml:
                headers["Content-Type"] = "application/xml; charset=utf-8"
            else:
                headers["Content-Type"] = "text/plain; charset=utf-8"
        xmlHttp = self.doCreateXmlHTTPRequest()

        def onreadystatechange(evnt=None):
            global xmlHttp, handler
            if xmlHttp.readyState == 4:
                # For IE:
                JS("delete xmlHttp.onreadystatechange;")
                localHandler = handler
                status = xmlHttp.status
                if returnxml:
                    response = xmlHttp.responseXML
                else:
                    response = xmlHttp.responseText;
                handler = None
                xmlHttp = None
                if status == 200 or status == 0:
                    localHandler.onCompletion(response);
                else:
                    localHandler.onError(response, status);
        xmlHttp.onreadystatechange = onreadystatechange

        try:
            xmlHttp.open(method, url, True);
            for h in headers:
{'fraction_non_alphanumeric': 0.09836448598130841, 'fraction_numerical': 0.007476635514018692, 'mean_word_length': 1.6199510403916768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 30}, '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': '6876929', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1075, 'n_words': 290}