<commit_before>var contextMenuClick = function(info, tab, callbackID) {
	chrome.tabs.sendMessage(tab.id, {
		requestType: "contextMenu.click",
		callbackID: callbackID
	});
};

chrome.runtime.onMessage.addListener(
	function(request, sender, sendResponse) {
		// all requests expect a JSON object with requestType and then the relevant
		// companion information...
		switch(request.requestType) {
			case 'xmlhttpRequest':
				var xhr = new XMLHttpRequest();
				xhr.open(request.method, request.url, true);
				if (request.method === "POST") {
					xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					// xhr.setRequestHeader("Content-length", request.data.length);
					// xhr.setRequestHeader("Connection", "close");					
				}
				xhr.onreadystatechange = function() {
					if (xhr.readyState === 4) {
						sendResponse(xhr);
					}
				};
				xhr.send(request.data);
				break;
			case 'createTab':
				var newIndex,
					focus = (request.background !== true);
				
				if (typeof(request.index) !== 'undefined') {
					newIndex = request.index;
				} else {
					// If index wasn't specified, get the selected tab so we can get the index of it.
					// This allows us to open our new tab as the "next" tab in order rather than at the end.
					newIndex = sender.tab.index+1;
				}<commit_msg>fixed an xhr bug in chrome<commit_after>var contextMenuClick = function(info, tab, callbackID) {
	chrome.tabs.sendMessage(tab.id, {
		requestType: "contextMenu.click",
		callbackID: callbackID
	});
};

chrome.runtime.onMessage.addListener(
	function(request, sender, sendResponse) {
		// all requests expect a JSON object with requestType and then the relevant
		// companion information...
		switch(request.requestType) {
			case 'xmlhttpRequest':
				var xhr = new XMLHttpRequest();
				xhr.open(request.method, request.url, true);
				if (request.method === "POST") {
					xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					// xhr.setRequestHeader("Content-length", request.data.length);
					// xhr.setRequestHeader("Connection", "close");					
				}
				xhr.onreadystatechange = function() {
					if (xhr.readyState === 4) {
						// Only store 'status' and 'responseText' fields and send them back.
						var response = {status: xhr.status, responseText: xhr.responseText};
						sendResponse(response);
					}
				};
				xhr.send(request.data);
				return true; // true must be returned here to indicate successful XHR
				break;
			case 'createTab':
				var newIndex,
					focus = (request.background !== true);
				
				if (typeof(request.index) !== 'undefined') {
					newIndex = request.index;
				} else {
					// If index wasn't specified, get the selected tab so we can get the index of it.
					// This allows us to open our new tab as the "next" tab in order rather than at the end.
					newIndex = sender.tab.index+1;
				}
{'fraction_non_alphanumeric': 0.12810773480662985, 'fraction_numerical': 0.0013812154696132596, 'mean_word_length': 3.1563845050215207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '7445243', 'n_tokens_mistral': 1079, 'n_tokens_neox': 861, 'n_words': 242}