<commit_before>﻿using System;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text;
using System.Timers;
using Newtonsoft.Json.Linq;

namespace BeerLightApp
{
    static class BeerLight
    {
        static int timeoutCount = 0; 
        public static String GetBeerLightStatus()
        {
            String urlAddress = "https://beer30v2.sparcedge.com/beer30.json";
            String data = null;
            String beerLightStatus = "none";
            HttpWebResponse response = null;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (Exception e)
            {
                using (StreamWriter write = File.AppendText("log.txt"))
                {
                    if (timeoutCount > 30)
                    {
                        Log(e, write, true);
                        Application.Exit();
                    }
                    else
                    {
                        Log(e, write, false);
                        beerLightStatus = "none";
                    }
                }
                timeoutCount++; 
            }

            if (response == null) { }
            else if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream recieveStream = response.GetResponseStream();
                StreamReader readStream = null;
                if (response.CharacterSet == null)
                {
                    readStream = new StreamReader(recieveStream);
                    Console.WriteLine("No Content Found...");
                    readStream.Close();
                }
                else
                {
                    readStream = new StreamReader(recieveStream, Encoding.GetEncoding(response.CharacterSet));
                    data = readStream.ReadToEnd();
                    JObject jsonObj = JObject.Parse(data);
                    beerLightStatus = (string)jsonObj["state"];
                    response.Close();
                    readStream.Close();
                }
            }
            return beerLightStatus;
        }<commit_msg>Possible timeout fix<commit_after>﻿using System;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text;
using System.Timers;
using Newtonsoft.Json.Linq;

namespace BeerLightApp
{
    static class BeerLight
    {
        static int timeoutCount = 0; 
        public static String GetBeerLightStatus()
        {
            String urlAddress = "https://beer30v2.sparcedge.com/beer30.json";
            String data = null;
            String beerLightStatus = "none";
            HttpWebResponse response = null;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (Exception e)
            {
                using (StreamWriter write = File.AppendText("log.txt"))
                {
                    if (timeoutCount > 30)
                    {
                        Log(e, write, true);
                        Application.Exit();
                    }
                    else
                    {
                        Log(e, write, false);
                        beerLightStatus = "none";
                    }
                }
                timeoutCount++; 
            }

            if (response == null) { beerLightStatus = "none"; }
            else if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream recieveStream = response.GetResponseStream();
                StreamReader readStream = null;
                if (response.CharacterSet == null)
                {
                    readStream = new StreamReader(recieveStream);
                    Console.WriteLine("No Content Found...");
                    readStream.Close();
                }
                else
                {
                    readStream = new StreamReader(recieveStream, Encoding.GetEncoding(response.CharacterSet));
                    data = readStream.ReadToEnd();
                    JObject jsonObj = JObject.Parse(data);
                    beerLightStatus = (string)jsonObj["state"];
                    response.Close();
                    readStream.Close();
                }
            }
            return beerLightStatus;
        }
{'fraction_non_alphanumeric': 0.08438818565400844, 'fraction_numerical': 0.0035531867643793028, 'mean_word_length': 1.19921875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1966424', 'n_tokens_mistral': 1070, 'n_tokens_neox': 991, 'n_words': 214}